0
Dictionary vs JSON
I had an interview, where the guy asked me whats the diff btw dictionary and JSON. I said both have same structure, only thing is in python it's an object, in JSON it's a collection or document. does anyone have a better answer ?
1 Answer
+ 2
JSON stands for JS Object Notation. So it's a notation, a format - merely a set of rules defining how to represent data in text format.
Python dict is a class representing hash table data structure in Python. It just happens to look like JSON; it's much more than that. It has non-trivial logic under the hood, including calculating hashes, memory management, updating the data etc etc. On top of that, both keys and values are Python objects ; you can store references to objects in memory in dict, which you could never do with JSON, because frankly, JSON is just a formatted string.
So these are completely different things, you can't even compare one to another.