def test_dict_in_dict(self): text = """{"test": {"hello": "world"}}""" ret = pyjsmn.loads(text) self.assertEqual(ret, {"test": {"hello": "world"}})
def test_dict_size_two(self): text = """{"hoge":null, "huga":134}""" ret = pyjsmn.loads(text) self.assertEqual(ret, {"hoge": None, "huga": 134})
def test_list_in_dict(self): text = """{"test": [1, "hello"]}""" ret = pyjsmn.loads(text) self.assertEqual(ret, {"test": [1, "hello"]})
def test_dict_size_one(self): text = """{"20":null}""" ret = pyjsmn.loads(text) self.assertEqual(ret, {'20': None})
def test_integer(self): text = "12" ret = pyjsmn.loads(text) self.assertEqual(ret, 12)
import pyjsmn jsonstr = """\ { "name" : "Jack", "age" : [ 1, 20, null] }""" print(pyjsmn.loads(jsonstr))
def test_list_size_two(self): text = "[false, -50.3]" ret = pyjsmn.loads(text) self.assertEqual(ret, [False, -50.3])
def test_false(self): text = "false" ret = pyjsmn.loads(text) self.assertEqual(ret, False)
def test_none(self): text = "null" ret = pyjsmn.loads(text) self.assertEqual(ret, None)
def test_string(self): text = "\"hello world\"" ret = pyjsmn.loads(text) self.assertEqual(ret, "hello world")
def test_true(self): text = "true" ret = pyjsmn.loads(text) self.assertEqual(ret, True)
def test_negative_float(self): text = "-12.3" ret = pyjsmn.loads(text) self.assertEqual(ret, -12.3)
def test_float(self): text = "12.3" ret = pyjsmn.loads(text) self.assertEqual(ret, 12.3)
def test_negative_integer(self): text = "-12" ret = pyjsmn.loads(text) self.assertEqual(ret, -12)
import pyjsmn jsonstr = """\ { "name" : "Jack", "pc" : {"windows": "XP", "linux": null}, "mail" : {"title": "good morning", "file": ["t.txt", "u.txt"]} }""" print pyjsmn.loads(jsonstr)
def test_list_size_one(self): text = "[null]" ret = pyjsmn.loads(text) self.assertEqual(ret, [None])
import pyjsmn string = """{"hello": "world"}""" print(pyjsmn.loads(string)) string = """{"hello": "world", "ola": 1}""" d = pyjsmn.loads(string) print(d)
"description":"This indicates the default for the instance property."}, "transient":{ "type":"boolean", "optional":true, "description":"This indicates that the property will be used for transient/volatile values that should not be persisted.", "default":false}, "maxDecimal":{ "type":"integer", "optional":true, "description":"This indicates the maximum number of decimal places in a floating point number."}, "hidden":{ "type":"boolean", "optional":true, "description":"This indicates whether the property should be hidden in user interfaces."}, "extends":{ "type":"object", "properties":{"$ref":"$.properties"}, "description":"This indicates the schema extends the given schema. All instances of this schema must be valid to by the extended schema also.", "optional":true, "default":{}}, "id":{ "type":["string","number"], "optional":true, "format":"url", "unique":true} } } """ jsonobj = pyjsmn.loads(jsonstr) print jsonobj