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.

    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.

MongoDB Logo MongoDB