Exemplo n.º 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)
Exemplo n.º 2
0
 def test_basic_object(self):
     self.assertEqual(pj.from_string('{"foo":"bar"}'), {"foo": "bar"})
Exemplo n.º 3
0
 def test_empty_object(self):
     self.assertEqual(pj.from_string('{}'), {})
Exemplo n.º 4
0
 def test_basic_whitespace(self):
     self.assertEqual(pj.from_string('{ "foo" : [1, 2, "three"] }'),
                      {"foo": [1, 2, "three"]})
Exemplo n.º 5
0
 def test_false(self):
     self.assertEqual(pj.from_string('{"foo":false}'), {"foo": False})
Exemplo n.º 6
0
 def test_true(self):
     self.assertEqual(pj.from_string('{"foo":null}'), {"foo": None})
Exemplo n.º 7
0
 def test_true(self):
     self.assertEqual(pj.from_string('{"foo":true}'), {"foo": True})
Exemplo n.º 8
0
 def test_nested_object(self):
     self.assertEqual(pj.from_string('{"foo":{"bar":2}}'),
                      {"foo": {
                          "bar": 2
                      }})
Exemplo n.º 9
0
 def test_empty_array(self):
     self.assertEqual(pj.from_string('{"foo":[]}'), {"foo": []})
Exemplo n.º 10
0
 def test_basic_number(self):
     self.assertEqual(pj.from_string('{"foo":1}'), {"foo": 1})
Exemplo n.º 11
0
import pj
print(pj.to_string(pj.from_string('{"foo":{"bar":[1,2,3]}}')))