1 from unittest
import TestCase
3 import simplejson
as json
5 # from http://json.org/JSON_checker/test/pass1.json
8 "JSON Test Pattern pass1",
9 {"object with 1 member":["array with 1 element"]},
17 "integer": 1234567890,
27 "controls": "\b\f\n\r\t",
29 "alpha": "abcdefghijklmnopqrstuvwyz",
30 "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
31 "digit": "0123456789",
32 "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
33 "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
39 "address": "50 St. James Street",
40 "url": "http://www.JSON.org/",
41 "comment": "// /* <!-- --",
43 " s p a c e d " :[1,2 , 3
48 "compact": [1,2,3,4,5,6,7],
49 "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
50 "quotes": "" \u0022 %22 0x22 034 "",
51 "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
52 : "A key can be any string"
65 class TestPass1(TestCase
):
67 # test in/out equivalence and parsing
68 res
= json
.loads(JSON
)
70 self
.assertEquals(res
, json
.loads(out
))
72 json
.dumps(res
, allow_nan
=False)
76 self
.fail("23456789012E666 should be out of range")