A naive question: As most developers, I periodically have a need to save data to disk. Few, few 10s, or few 100s values. Most people use XML, some use JSON, but I always feel that the good old ini-file format
key1=value1
key2=value2
meets my needs best. The files are very readable, one can easily use text-processing on them, diffs in version control work well.
Yet, it seems that key=value is not a very popular in serialization. Am I overlooking something?
It really depends on what you’re trying to do with those values. With JSON, you can nest arrays of objects (each with their own sets of name/value pairs) in a concise format. Obviously with XML, you can deeply nest objects, and each object can have a number of attributes (which end up being name/value pairs).
So it comes down to a matter of style.
Do you like:
or
or
I think if you need to do searching and filtering, XML is probably the format for you. If you’re using your data within JavaScript or sending it to and from different services, JSON is probably the preferred format. And if it’s just data that you need to work with internally, an INI file format is perfectly fine.
Probably not what you want to hear, but, in my opinion, it really depends.