예제 #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
파일: life.py 프로젝트: dumpforjunk/pyjsmn
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
파일: test2.py 프로젝트: dumpforjunk/pyjsmn
     	"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