While working on json format, came across something interesting.
As we can see here, json isnt preserving tuples. On searching, I got to know, JSON doesnt understand tuples. These are the basic data types for json(from Wikipedia )
sample_list = [(1,2),(3,4)]
print json.dumps(sample_list) # [[1,2],[3,4]]
As we can see here, json isnt preserving tuples. On searching, I got to know, JSON doesnt understand tuples. These are the basic data types for json(from Wikipedia )
JSON's basic types are:
- Number (double precision floating-point format in JavaScript, generally depends on implementation)
- Boolean (
true
orfalse
)
- Array (an ordered sequence of values, comma-separated and enclosed in square brackets; the values do not need to be of the same type)
- Object (an unordered collection of key:value pairs with the ':' character separating the key and the value, comma-separated and enclosed in curly braces; the keys must be strings and should be distinct from each other)
null
(empty)
Here are some solutions for the same on stackoverflow.
Cheers..!!
No comments:
Post a Comment