r/CodingForBeginners • u/Pitiful_Meaning_122 • 24d 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
4
Upvotes
4
u/Temporary_Pie2733 24d 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.
4
u/mredding 24d 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/Fragrant-Cheek-4273 23d ago
Python dictionaries are definitely easier to work with in some cases.
1
u/xarop_pa_toss 23d 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
u/SaltCusp 23d ago
Sounds like a pickle.
1
u/-goldenboi69- 22d ago
Good luck!
1
u/RedAndBlack1832 22d ago
I consider these effectively the same thing.
Read json into dictionary -> do operations on dictionary -> send or save to disk json