Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for answer to dictionary to JSON? by martineau

Current License: CC BY-SA 3.0

Post Revisions

14 events
when toggle format what by license comment
Jul 26, 2015 at 0:01 comment added martineau @HR123r: Don't think that's a good idea since it has little to do with this question. Suggest you try taking the output produced here and reverse-transforming it back into the original structure. Then, if you can't figure that out, post a separate question here on SO describing what you want to do and showing your attempt.
Jul 25, 2015 at 23:15 history edited martineau CC BY-SA 3.0
Increased indentation of output so the structure is easier to read.
Jul 25, 2015 at 21:25 comment added HR123r @martineau I have been looking a lot around the internet, and I can't seem to find an example on how to build the terms dictionary. Do you thin you can post a tutorial for it, or change your answer to incorporate that? It would be really helpful. Thank you.
Jul 23, 2015 at 18:53 comment added martineau I guess you could think of it as a Tree representation using pointers (the node id strings).
Jul 23, 2015 at 18:49 comment added martineau Yes — I misspoke. It's a dict of dicts, but the physical nesting never goes any deeper (so it'll never become a dict of dicts of dicts of ...etc) but logically it can represent that.
Jul 23, 2015 at 18:41 comment added HR123r @martineau: Thank you! I see that it's dict of dicts but the 'p' and 'c' have lists right?
Jul 23, 2015 at 18:29 comment added martineau Although there's only one dictionary here, it contains the nodes of the whole Tree, which are represented with id strings here — so it's equivalent to a dictionary of dictionaries. That means it should be possible to convert one into the other. Therefor, I think, that you can think about and do things with whichever representation is the most convenient for you (and convert it the other as needed). If I run across and good example or reference like you want, I'll let you know.
Jul 23, 2015 at 18:15 comment added HR123r @martineau: Thank you, I looked up autovivification in python, the point I am missing is that in autovivification is like dictionary of dicts, here it's a dictionary of dictionaries with lists as the values. How about this exact format, how do we reach it. Thank you
Jul 23, 2015 at 17:26 comment added martineau @HR123r: One very flexible way is by something called "autovivification". More generally, look up things related to building the data-structure known as a "Tree". They can also be represented as nested sequences.
Jul 23, 2015 at 16:45 comment added HR123r my question is how to go go about the build the terms dictionary to begin with? Any link to relevant API or other resources would be great. thanks!
Apr 30, 2015 at 11:54 comment added martineau It's possible to do it without recursion, however doing so requires an auxiliary data structure like a stack or queue to keep track of things, so is often more complicated. Recursion effectively replaces that with the program's own function call stack.
Apr 30, 2015 at 11:35 comment added Henkes Thanks the recursive transform function is exactly what I needed! With regular for loops it didn't work.
Apr 30, 2015 at 11:34 vote accept Henkes
Apr 30, 2015 at 11:21 history answered martineau CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /