A python implementation for TJSON: Tagged JSON with Rich Types.
Coming soon
To parse a TJSON document:
>> from pytjson import tjson
>> my_tjson = tjson()
>> my_tjson.parse('{"foo:s":"bar"}')
{'foo': 'bar'}The following describes how TJSON types map onto Python types during parsing:
- Unicode Strings: parsed as Python's
StringwithEncoding::UTF_8 - Binary Data: parsed as python
bytes - Integers: parsed as python
Int - Floats (i.e. JSON number literals): parsed as python
float - Timestamps: parsed as python
datetime.datetime - Arrays: parsed as python
list - Objects: parsed as
TJSON::Object(a subclass of::Dict)
To generate TJSON from Pytjon's objects, use the generate() method:
>> from pytjson.tjson import tjson
>> my_tjson = tjson()
>> my_tjson.generate({"foo" => "bar"})
{"foo:s:"bar"}