예제 #1
0
 def test_afert_colon_not_key(self):
     try:
         pj.from_string('{ "foo" 1 [1, 2, "three"] }')
     except Exception as e:
         self.assertEqual(str(e),
                          "Expected colon after key in object, got: 1")
     else:
         self.assertEqual(true, false)
예제 #2
0
 def test_basic_object(self):
     self.assertEqual(pj.from_string('{"foo":"bar"}'), {"foo": "bar"})
예제 #3
0
 def test_empty_object(self):
     self.assertEqual(pj.from_string('{}'), {})
예제 #4
0
 def test_basic_whitespace(self):
     self.assertEqual(pj.from_string('{ "foo" : [1, 2, "three"] }'),
                      {"foo": [1, 2, "three"]})
예제 #5
0
 def test_false(self):
     self.assertEqual(pj.from_string('{"foo":false}'), {"foo": False})
예제 #6
0
 def test_true(self):
     self.assertEqual(pj.from_string('{"foo":null}'), {"foo": None})
예제 #7
0
 def test_true(self):
     self.assertEqual(pj.from_string('{"foo":true}'), {"foo": True})
예제 #8
0
 def test_nested_object(self):
     self.assertEqual(pj.from_string('{"foo":{"bar":2}}'),
                      {"foo": {
                          "bar": 2
                      }})
예제 #9
0
 def test_empty_array(self):
     self.assertEqual(pj.from_string('{"foo":[]}'), {"foo": []})
예제 #10
0
 def test_basic_number(self):
     self.assertEqual(pj.from_string('{"foo":1}'), {"foo": 1})
예제 #11
0
import pj
print(pj.to_string(pj.from_string('{"foo":{"bar":[1,2,3]}}')))