当前位置: 首页>>代码示例>>Python>>正文


Python ujson.decode函数代码示例

本文整理汇总了Python中ujson.decode函数的典型用法代码示例。如果您正苦于以下问题:Python decode函数的具体用法?Python decode怎么用?Python decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了decode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_encodeDictConversion

 def test_encodeDictConversion(self):
     input = { "k1": 1, "k2":  2, "k3": 3, "k4": 4 }
     output = ujson.encode(input)
     self.assertEquals(input, json.loads(output))
     self.assertEquals(input, ujson.decode(output))
     self.assertEquals(input, ujson.decode(output))
     pass
开发者ID:benjamn,项目名称:ultrajson,代码行数:7,代码来源:tests.py

示例2: test_dynamic_by_name

 def test_dynamic_by_name(self):
     VISITOR_ID_1 = uuid.uuid4().hex
     EVENT_1 = "Event 1 %s" % uuid.uuid4().hex
     EVENT_2 = "Event 2 %s" % uuid.uuid4().hex
     yield self.post_event(VISITOR_ID_1, EVENT_1)
     yield self.post_event(VISITOR_ID_1, EVENT_2)
     events = yield self.get_event_dict()
     event_id_1 = events[EVENT_1]
     event_id_2 = events[EVENT_2]
     qs = urlencode([("event", EVENT_1), ("event", EVENT_2)])
     result = yield request(
         "GET",
         "%s/funnel?%s" % (self.url, qs),
         username=self.username,
         password=self.password) 
     self.assertEqual(result.code, 200)
     returned_event_ids = ujson.decode(result.body)["event_ids"]
     self.assertTrue(event_id_1 in returned_event_ids)
     self.assertTrue(event_id_2 in returned_event_ids)
     funnel = ujson.decode(result.body)["funnel"]
     unique_funnel = ujson.decode(result.body)["unique_funnel"]
     self.assertEqual(funnel[0][0], event_id_1)
     self.assertEqual(funnel[1][0], event_id_2)
     self.assertEqual(funnel[0][1], 1)
     self.assertEqual(funnel[1][1], 1)
     self.assertEqual(unique_funnel[0][0], event_id_1)
     self.assertEqual(unique_funnel[1][0], event_id_2)
     self.assertEqual(unique_funnel[0][1], 1)
     self.assertEqual(unique_funnel[1][1], 1)
开发者ID:hiidef,项目名称:hiitrack-api,代码行数:29,代码来源:funnel.py

示例3: is_valid_json

 def is_valid_json(json: str) -> bool:
     try:
         ujson.decode(json)
     except:
         return False
     else:
         return True
开发者ID:ChrisCalderon,项目名称:dapper,代码行数:7,代码来源:rpc_client_base.py

示例4: test_decodeJibberish

 def test_decodeJibberish(self):
     input = "fdsa sda v9sa fdsa"
     try:
         ujson.decode(input)
         assert False, "Expected exception!"
     except(ValueError):
         return
     assert False, "Wrong exception"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例5: test_decodeWithTrailingNonWhitespaces

 def test_decodeWithTrailingNonWhitespaces(self):
     try:
         input = "{}\n\t a"
         ujson.decode(input)
     except ValueError:
         pass
     else:
         assert False, "expected ValueError"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例6: test_decodeNullBroken

 def test_decodeNullBroken(self):
     input = "n"
     try:
         ujson.decode(input)
         assert False, "Expected exception!"
     except(ValueError):
         return
     assert False, "Wrong exception"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例7: test_decodeStringUnterminated

 def test_decodeStringUnterminated(self):
     input = "\"TESTING"
     try:
         ujson.decode(input)
         assert False, "Expected exception!"
     except(ValueError):
         return
     assert False, "Wrong exception"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例8: test_decodeStringBadEscape

 def test_decodeStringBadEscape(self):
     input = "\"TESTING\\\""
     try:
         ujson.decode(input)
         assert False, "Expected exception!"
     except(ValueError):
         return
     assert False, "Wrong exception"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例9: test_decodeBrokenObjectStart

 def test_decodeBrokenObjectStart(self):
     input = "{"
     try:
         ujson.decode(input)
         assert False, "Expected exception!"
     except(ValueError):
         return
     assert False, "Wrong exception"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例10: test_decodeTooBigValue

 def test_decodeTooBigValue(self):
     try:
         input = "9223372036854775808"
         ujson.decode(input)
     except ValueError as e:
         pass
     else:
         assert False, "expected ValueError"
开发者ID:Jahaja,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例11: test_decodeVeryTooBigValue

 def test_decodeVeryTooBigValue(self):
     try:
         input = "18446744073709551616"
         ujson.decode(input)
     except ValueError:
         pass
     else:
         assert False, "expected ValueError"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例12: test_decodeArrayOnlyCommaFail

 def test_decodeArrayOnlyCommaFail(self):
     input = "[,]"
     try:
         ujson.decode(input)
     except ValueError:
         pass
     else:
         assert False, "expected ValueError"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例13: test_decodeArrayUnmatchedBracketFail

 def test_decodeArrayUnmatchedBracketFail(self):
     input = "[]]"
     try:
         ujson.decode(input)
     except ValueError:
         pass
     else:
         assert False, "expected ValueError"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例14: test_decodeStringUntermEscapeSequence

 def test_decodeStringUntermEscapeSequence(self):
     input = '"TESTING\\"'
     try:
         ujson.decode(input)
         assert False, "Expected exception!"
     except (ValueError):
         return
     assert False, "Wrong exception"
开发者ID:stantonk,项目名称:ultrajson,代码行数:8,代码来源:tests.py

示例15: test_goodreads

 def test_goodreads(self):
     def autogenerate_goodreads(*args, **kwargs):
         autogenerator = delta.Autogenerator(paths="books", includes="books/id")
         return [x.data for x in autogenerator(*args, **kwargs)]
     from ujson import decode
     old = decode(read("%s/goodreads/old.json" % DATAPATH))
     new = decode(read("%s/goodreads/new.json" % DATAPATH))
     self.assertEqual(autogenerate_goodreads(old, new), [])
开发者ID:hiidef,项目名称:hiispider,代码行数:8,代码来源:delta.py


注:本文中的ujson.decode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。