sisl / ngsim_env

Learning human driver models from NGSIM data with imitation learning.
https://arxiv.org/abs/1803.01044
MIT License
172 stars 80 forks source link

How to retrieve and store JSON data in a Dictionary by providing keys separated by colon “:” #18

Closed Imfao closed 5 years ago

Imfao commented 5 years ago

It's a C# console app, I'd like to make JSON interact with a Dictionary by passing keys separated by colon, the keys of the dictionary are expected to be passed in the form of "key1:key1-1:key1-1-1", the path of keys is fixed like that, so I'm told not to use outer string-manipulating functions.

Here is my sample JSON

{
    "One": "Hey",

    "Two": {
               "Two": "HeyHey"
           }

    "Three": {
                 "Three": {
                              "Three": "HeyHeyHey"  
                          }
             } 
}

"HeyHeyHey" shall be the expected value for dictionary["Three:Three:Three"] according to the sample JSON. How do I store JSON data into a Dictionary in the form of dictionary["Three:Three:Three"], not dictionary["Three"]["Three"]["Three"]. I thought of using string-manipulating functions to operate on JSON keys, but I'm told that the program will not call my functions.