示例#1
0
 def test_dict_in_dict(self):
     text = """{"test": {"hello": "world"}}"""
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, {"test": {"hello": "world"}})
示例#2
0
 def test_dict_size_two(self):
     text = """{"hoge":null, "huga":134}"""
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, {"hoge": None, "huga": 134})
示例#3
0
 def test_list_in_dict(self):
     text = """{"test": [1, "hello"]}"""
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, {"test": [1, "hello"]})
示例#4
0
 def test_dict_size_one(self):
     text = """{"20":null}"""
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, {'20': None})
示例#5
0
 def test_integer(self):
     text = "12"
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, 12)
示例#6
0
import pyjsmn

jsonstr = """\
{
    "name" : "Jack",
    "age" : [ 1, 20, null]
}"""
print(pyjsmn.loads(jsonstr))
示例#7
0
 def test_list_size_two(self):
     text = "[false, -50.3]"
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, [False, -50.3])
示例#8
0
 def test_false(self):
     text = "false"
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, False)
示例#9
0
 def test_none(self):
     text = "null"
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, None)
示例#10
0
 def test_string(self):
     text = "\"hello world\""
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, "hello world")
示例#11
0
 def test_true(self):
     text = "true"
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, True)
示例#12
0
 def test_negative_float(self):
     text = "-12.3"
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, -12.3)
示例#13
0
 def test_float(self):
     text = "12.3"
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, 12.3)
示例#14
0
 def test_negative_integer(self):
     text = "-12"
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, -12)
示例#15
0
import pyjsmn

jsonstr = """\
{
    "name" : "Jack",
    "pc" : {"windows": "XP", "linux": null},
    "mail" : {"title": "good morning",
              "file": ["t.txt", "u.txt"]}
}"""
print pyjsmn.loads(jsonstr)
示例#16
0
 def test_list_size_one(self):
     text = "[null]"
     ret = pyjsmn.loads(text)
     self.assertEqual(ret, [None])
示例#17
0
import pyjsmn

string = """{"hello": "world"}"""
print(pyjsmn.loads(string))

string = """{"hello": "world", "ola": 1}"""
d = pyjsmn.loads(string)
print(d)
示例#18
0
     	"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