def test_js_to_json_edgecases(self):
    on = js_to_json('{abc_def:\'1\\\'\\\\2\\\\\\\'3"4\'}')
    self.assertEqual(json.loads(on), {'abc_def': '1\'\\2\\\'3"4'})
    on = js_to_json('{"abc": true}')
    self.assertEqual(json.loads(on), {'abc': True})
    on = js_to_json('{\n            "x": 1,\n            y: "a",\n            z: some.code\n        }')
    d = json.loads(on)
    self.assertEqual(d['x'], 1)
    self.assertEqual(d['y'], 'a')
    on = js_to_json('{\n            a: !0,\n            b: !1,\n            c: !!0,\n            d: !!42.42,\n            e: !!![],\n            f: !"abc",\n            g: !"",\n            !42: 42\n        }')
    self.assertEqual(json.loads(on), {'a': 0, 'b': 1, 'c': 0, 'd': 42.42, 'e': [], 'f': 'abc', 'g': '', '42': 42})
    on = js_to_json('["abc", "def",]')
    self.assertEqual(json.loads(on), ['abc', 'def'])
    on = js_to_json('[/*comment\n*/"abc"/*comment\n*/,/*comment\n*/"def",/*comment\n*/]')
    self.assertEqual(json.loads(on), ['abc', 'def'])
    on = js_to_json('[//comment\n"abc" //comment\n,//comment\n"def",//comment\n]')
    self.assertEqual(json.loads(on), ['abc', 'def'])
    on = js_to_json('{"abc": "def",}')
    self.assertEqual(json.loads(on), {'abc': 'def'})
    on = js_to_json('{/*comment\n*/"abc"/*comment\n*/:/*comment\n*/"def"/*comment\n*/,/*comment\n*/}')
    self.assertEqual(json.loads(on), {'abc': 'def'})
    on = js_to_json('{ 0: /* " \n */ ",]" , }')
    self.assertEqual(json.loads(on), {'0': ',]'})
    on = js_to_json('{ /*comment\n*/0/*comment\n*/: /* " \n */ ",]" , }')
    self.assertEqual(json.loads(on), {'0': ',]'})
    on = js_to_json('{ 0: // comment\n1 }')
    self.assertEqual(json.loads(on), {'0': 1})
    on = js_to_json('["<p>x<\\/p>"]')
    self.assertEqual(json.loads(on), ['<p>x</p>'])
    on = js_to_json('["\\xaa"]')
    self.assertEqual(json.loads(on), ['ª'])
    on = js_to_json("['a\\\nb']")
    self.assertEqual(json.loads(on), ['ab'])
    on = js_to_json("/*comment\n*/[/*comment\n*/'a\\\nb'/*comment\n*/]/*comment\n*/")
    self.assertEqual(json.loads(on), ['ab'])
    on = js_to_json('{0xff:0xff}')
    self.assertEqual(json.loads(on), {'255': 255})
    on = js_to_json('{/*comment\n*/0xff/*comment\n*/:/*comment\n*/0xff/*comment\n*/}')
    self.assertEqual(json.loads(on), {'255': 255})
    on = js_to_json('{077:077}')
    self.assertEqual(json.loads(on), {'63': 63})
    on = js_to_json('{/*comment\n*/077/*comment\n*/:/*comment\n*/077/*comment\n*/}')
    self.assertEqual(json.loads(on), {'63': 63})
    on = js_to_json('{42:42}')
    self.assertEqual(json.loads(on), {'42': 42})
    on = js_to_json('{/*comment\n*/42/*comment\n*/:/*comment\n*/42/*comment\n*/}')
    self.assertEqual(json.loads(on), {'42': 42})
    on = js_to_json('{42:4.2e1}')
    self.assertEqual(json.loads(on), {'42': 42.0})
    on = js_to_json('{ "0x40": "0x40" }')
    self.assertEqual(json.loads(on), {'0x40': '0x40'})
    on = js_to_json('{ "040": "040" }')
    self.assertEqual(json.loads(on), {'040': '040'})
    on = js_to_json('[1,//{},\n2]')
    self.assertEqual(json.loads(on), [1, 2])
def test_js_to_json_edgecases(self):
    on = js_to_json('{abc_def:\'1\\\'\\\\2\\\\\\\'3"4\'}')
    self.assertEqual(json.loads(on), {'abc_def': '1\'\\2\\\'3"4'})
    on = js_to_json('{"abc": true}')
    self.assertEqual(json.loads(on), {'abc': True})
    on = js_to_json('{\n            "x": 1,\n            y: "a",\n            z: some.code\n        }')
    d = json.loads(on)
    self.assertEqual(d['x'], 1)
    self.assertEqual(d['y'], 'a')
    on = js_to_json('{\n            a: !0,\n            b: !1,\n            c: !!0,\n            d: !!42.42,\n            e: !!![],\n            f: !"abc",\n            g: !,\n            !42: 42\n        }')
    self.assertEqual(json.loads(on), {'a': 0, 'b': 1, 'c': 0, 'd': 42.42, 'e': [], 'f': 'abc', 'g': , '42': 42})
    on = js_to_json('["abc", "def",]')
    self.assertEqual(json.loads(on), ['abc', 'def'])
    on = js_to_json('[/*comment\n*/"abc"/*comment\n*/,/*comment\n*/"def",/*comment\n*/]')
    self.assertEqual(json.loads(on), ['abc', 'def'])
    on = js_to_json('[//comment\n"abc" //comment\n,//comment\n"def",//comment\n]')
    self.assertEqual(json.loads(on), ['abc', 'def'])
    on = js_to_json('{"abc": "def",}')
    self.assertEqual(json.loads(on), {'abc': 'def'})
    on = js_to_json('{/*comment\n*/"abc"/*comment\n*/:/*comment\n*/"def"/*comment\n*/,/*comment\n*/}')
    self.assertEqual(json.loads(on), {'abc': 'def'})
    on = js_to_json('{ 0: /* " \n */ ",]" , }')
    self.assertEqual(json.loads(on), {'0': ',]'})
    on = js_to_json('{ /*comment\n*/0/*comment\n*/: /* " \n */ ",]" , }')
    self.assertEqual(json.loads(on), {'0': ',]'})
    on = js_to_json('{ 0: // comment\n1 }')
    self.assertEqual(json.loads(on), {'0': 1})
    on = js_to_json('["<p>x<\\/p>"]')
    self.assertEqual(json.loads(on), ['<p>x</p>'])
    on = js_to_json('["\\xaa"]')
    self.assertEqual(json.loads(on), ['ª'])
    on = js_to_json("['a\\\nb']")
    self.assertEqual(json.loads(on), ['ab'])
    on = js_to_json("/*comment\n*/[/*comment\n*/'a\\\nb'/*comment\n*/]/*comment\n*/")
    self.assertEqual(json.loads(on), ['ab'])
    on = js_to_json('{0xff:0xff}')
    self.assertEqual(json.loads(on), {'255': 255})
    on = js_to_json('{/*comment\n*/0xff/*comment\n*/:/*comment\n*/0xff/*comment\n*/}')
    self.assertEqual(json.loads(on), {'255': 255})
    on = js_to_json('{077:077}')
    self.assertEqual(json.loads(on), {'63': 63})
    on = js_to_json('{/*comment\n*/077/*comment\n*/:/*comment\n*/077/*comment\n*/}')
    self.assertEqual(json.loads(on), {'63': 63})
    on = js_to_json('{42:42}')
    self.assertEqual(json.loads(on), {'42': 42})
    on = js_to_json('{/*comment\n*/42/*comment\n*/:/*comment\n*/42/*comment\n*/}')
    self.assertEqual(json.loads(on), {'42': 42})
    on = js_to_json('{42:4.2e1}')
    self.assertEqual(json.loads(on), {'42': 42.0})
    on = js_to_json('{ "0x40": "0x40" }')
    self.assertEqual(json.loads(on), {'0x40': '0x40'})
    on = js_to_json('{ "040": "040" }')
    self.assertEqual(json.loads(on), {'040': '040'})
    on = js_to_json('[1,//{},\n2]')
    self.assertEqual(json.loads(on), [1, 2])