This may be the most foolish question. But I just wanted to hear from the experience people. Why use JSON in Python? Is it to create code compatible or something like that? I once heard from my supervisor that someone will write the Python function and it will return JSON Object then the function can be used in Objective C? Is that even possible? Please Explain!! Thank you!
Share
Suppose you do some computation in python that returns a list; and suppose this list needs to be later used by some C program.
Then, one way you can solve this issue is to write the list out into a file and make the C program read the list out of that file. In order to accomplish this, you need to write the list into the file in such a way that you can read it back correctly in the C program.
While there is nothing wrong with writing it as such, you might want to save some time in defining a file-storage protocol (or way of writing to and reading from file. It’s actually called marshalling and de-marshalling or serialization and desierialization) and writing the necessary code to write to file and read from it. Thus, you might want to use popular marshalling and de-marshalling protocols for which most languages have libraries. JSON is one such popular marshalling protocol. Others include Pickle and protobuf.
Hope this helps