You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.
If I encode and decode the integer 1, I get a ValueError:
In [9]: yajl.loads("1")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/tmp/py-yajl/<ipython console> in <module>()
ValueError: eof was met before the parse could complete
1 seems to be valid JSON according to http://www.jsonlint.com/ and also JSON.stringify(1) returns '1' and simplejson and cjson successfully decode '1' as 1.
Adding a newline or space to the end of the string fixes the problem.
In [20]: yajl.loads("1 ")
Out[20]: 1
In [18]: yajl.loads("1\n")
Out[18]: 1
Another reason why this behavior seems odd is that yajl.dumps(1) returns '1' which then can't be yajl.loads-ed. It seems like any output from yajl.dumps should be valid input to yajl.loads.
The text was updated successfully, but these errors were encountered:
The fact that this works with a newline or a space at the end of the string is likely a bug.
The reason yajl.loads("1") doesn't work is because it's a JSON fragment and not a JSON object. From json.org:
JSON is built on two structures:
* A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
* An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
The other issue here is that ValueError isn't a descriptive error at all. I should correct that too
If I encode and decode the integer 1, I get a ValueError:
1 seems to be valid JSON according to http://www.jsonlint.com/ and also JSON.stringify(1) returns '1' and simplejson and cjson successfully decode '1' as 1.
Adding a newline or space to the end of the string fixes the problem.
Another reason why this behavior seems odd is that yajl.dumps(1) returns '1' which then can't be yajl.loads-ed. It seems like any output from yajl.dumps should be valid input to yajl.loads.
The text was updated successfully, but these errors were encountered: