• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python ujson.decode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_decodeVeryTooSmallValue

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


示例17: test_decodeObjectDepthTooBig

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


示例18: test_decodeDictWithNoValue

    def test_decodeDictWithNoValue(self):
        input = "{{{{\"key\":}}}}"
        try:
            ujson.decode(input)
            assert False, "Expected exception!"
        except(ValueError):
            return

        assert False, "Wrong exception"
开发者ID:karanlyons,项目名称:ultrajson,代码行数:9,代码来源:tests.py


示例19: test_decodeDictWithNoColonOrValue

    def test_decodeDictWithNoColonOrValue(self):
        input = '{{{{"key"}}}}'
        try:
            ujson.decode(input)
            assert False, "Expected exception!"
        except (ValueError):
            return

        assert False, "Wrong exception"
开发者ID:stantonk,项目名称:ultrajson,代码行数:9,代码来源:tests.py


示例20: test_decodeBigEscape

 def test_decodeBigEscape(self):
     for x in range(10):
         if six.PY3:
             base = '\u00e5'.encode('utf-8')
             quote = "\"".encode()
         else:
             base = "\xc3\xa5"
             quote = "\""
         input = quote + (base * 1024 * 1024 * 2) + quote
         ujson.decode(input)
开发者ID:esnme,项目名称:ultrajson,代码行数:10,代码来源:tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ujson.dump函数代码示例发布时间:2022-05-27
下一篇:
Python settings.SettingsDialog类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap