none
question about parsing a file into key/values ( but cant use dictionary as some keys are the same. ) RRS feed

  • Question

  • so this is the file im trying to edit and this is its santx 

    file to parse into key/value

    so everything inside 

    	"ballista_az" ( "bulletweapon.gdf" )
    	{
    
            }

    this function in my program i will create a text box for each key/value so for examople i want to be able to parse the file to have the key witch would be for example one of the keys would be = "activate_mode" and i would want to display the value of "activate_mode" witch would be "hold" into the text box 

    would do this for all of them and the user could edit them as they please then i want a save button and it will save out the weapon the file bearing in mind the file has loads more in it but its just the value of each key i want to edit nothing else and i not sure how to go about doing it 

    any help would be much appropriated Mion~

    Saturday, March 24, 2018 4:35 AM

All replies

  • Hello Mion,

    >>question about parsing a file into key/values ( but cant use dictionary as some keys are the same. )  

    The file you provided isn't a common json or xml format. It means you need to parse it by custom method. For how to store key/values, you could try to use  List<KeyValuePair<T1,T2>>, which does not enforce uniqueness of the key. Or you try to use Lookup<tkey, telement>Class</tkey, telement> and it represents a collection of keys each mapped to one or more values. As for how to save the changed value. You just need to loop the collection and write it to stream line by line. This is a easy process to achieve your requirement.

    And if you have any concerns, please do not hesitate to let us know.

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 26, 2018 8:27 AM
    Moderator
  • Hello Mion,

    >>question about parsing a file into key/values ( but cant use dictionary as some keys are the same. )  

    The file you provided isn't a common json or xml format. It means you need to parse it by custom method and also save method. For how to store key/values, you could try to use  List<KeyValuePair<T1,T2>>, which does not enforce uniqueness of the key. Or you try to use Lookup<tkey, telement>Class</tkey, telement> and it represents a collection of keys each mapped to one or more values. As for how to save the changed value. You just need to loop the collection and write it to stream line by line. This is a easy process to achieve your requirement.

    And if you have any concerns, please do not hesitate to let us know.

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    well i know the file is gdt file but that like black ops 3 own format so im not sure if its json or not is there a way of telling if its json or not ? 
    Thursday, March 29, 2018 10:17 PM
  • Hello,

     Another person asked the SAME question and about the SAME file format.

    So, a few months ago, I did them the favor and wrote a dirty Parser. Dirty

    as in the basic framework and nothing else.  Here is the link;

     

     https://1drv.ms/u/s!AnZy9F1PKht-gQFh5Xifbj25eiaZ

     

     Please, PLEASE... Examine the code and Debug an execution.

    Learn by doing.

     Hope this helps :)

    Friday, March 30, 2018 1:40 AM