Menu

Subkeys in Value

2014-06-20
2014-07-05
  • Ranjeet Kuruvilla

    Hello
    I would like to be able to pass keys in the form of
    "Key.Subkey.Subsubkey"
    to create an entry in the form of

    Key: {
    Subkey: {
    Subsubkey:
    }
    }

    Is there a way to do that? Of course the delimiter between "Key" and
    "Subkey" need not to be '.'
    Regards

     
  • Christopher Dunn

    You can write a small function which traverses the hierarchy, calling isMember() followed by get() at each level.
    - http://cdunn2001.github.io/json-cpp/doxygen/class_json_1_1_value.html

    It's not a useful method to add because there are too many potential variations.
    - what delimiter?
    - what to do when not found?
    - what if intermediate value not found?
    - should it distinguish between intermediate arrays and dictionaries?

     

    Last edit: Christopher Dunn 2014-07-05

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.