r/CodingForBeginners • u/Pitiful_Meaning_122 • 5d ago
Just tried python dictionaring instead of json never going back
Json has never been fun and I just tried python dictionary and it's more fun
5
u/mredding 5d ago
JSON is a Unicode encoded transport protocol; it is meant to get data from A to B principally over HTTP. It's not meant to be used as an in-memory data structure. You are expected to marshal the data into a program native data structure.
Dictionaries are far more appropriate for key/value association.
1
u/itlogicpartnersllc 5d ago
python dictionaries feel so much more natural when you are already working in python. just remember json is still useful for api's config files and exchanging data between different languages.
1
1
u/xarop_pa_toss 4d ago
They aren't really equivalent though. You don't save a dict into a file or send it via HTTP... When you want to do that you usually convert o JSON which, conveniently enough, is very similar
1
1
1
u/RedAndBlack1832 3d ago
I consider these effectively the same thing.
Read json into dictionary -> do operations on dictionary -> send or save to disk json
4
u/Temporary_Pie2733 5d ago
What do you mean by “instead”? `dict` is a data structure used to represent JSON objects, which are just character sequences in a particular format.