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

Python ultrajson.decode函数代码示例

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

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



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

示例1: test_decodeNullBroken

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


示例2: test_decodeWithTrailingNonWhitespaces

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


示例3: test_decodeObjectDepthTooBig

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


示例4: test_decodeArrayUnmatchedBracketFail

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


示例5: test_decodeBrokenObjectStart

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


示例6: test_decodeArrayOnlyCommaFail

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


示例7: test_decodeVeryTooSmallValue

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


示例8: test_decodeJibberish

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


示例9: test_decodeVeryTooBigValue

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


示例10: test_decodeStringBadEscape

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


示例11: test_decodeStringUnterminated

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


示例12: test_decodeDictWithNoValue

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

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


示例13: test_encodeLongNegConversion

    def test_encodeLongNegConversion(self):
        input = -9223372036854775808
        output = ultrajson.encode(input)

        outputjson = json.loads(output)
        outputultrajson = ultrajson.decode(output)

        self.assertEqual(input, json.loads(output))
        self.assertEqual(output, json.dumps(input))
        self.assertEqual(input, ultrajson.decode(output))
开发者ID:darthghandi,项目名称:ultrajson,代码行数:10,代码来源:tests.py


示例14: test_decodeBrokenDictKeyTypeLeakTest

    def test_decodeBrokenDictKeyTypeLeakTest(self):
        input = '{{1337:""}}'
        for x in range(1000):
            try:
                ultrajson.decode(input)
                assert False, "Expected exception!"
            except(ValueError) as e:
                continue

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


示例15: test_decodeBrokenListLeakTest

    def test_decodeBrokenListLeakTest(self):
        input = '[[[true'
        for x in range(1000):
            try:
                ultrajson.decode(input)
                assert False, "Expected exception!"
            except(ValueError):
                continue

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


示例16: test_doublePrecisionTest

    def test_doublePrecisionTest(self):
        input = 30.012345678901234
        output = ultrajson.encode(input, double_precision = 15)
        self.assertEqual(input, json.loads(output))
        self.assertEqual(input, ultrajson.decode(output))

        output = ultrajson.encode(input, double_precision = 9)
        self.assertEqual(round(input, 9), json.loads(output))
        self.assertEqual(round(input, 9), ultrajson.decode(output))

        output = ultrajson.encode(input, double_precision = 3)
        self.assertEqual(round(input, 3), json.loads(output))
        self.assertEqual(round(input, 3), ultrajson.decode(output))
开发者ID:darthghandi,项目名称:ultrajson,代码行数:13,代码来源:tests.py


示例17: test_encodeNullCharacter

    def test_encodeNullCharacter(self):
        input = "31337 \x00 1337"
        output = ultrajson.encode(input)
        self.assertEqual(input, json.loads(output))
        self.assertEqual(output, json.dumps(input))
        self.assertEqual(input, ultrajson.decode(output))

        input = "\x00"
        output = ultrajson.encode(input)
        self.assertEqual(input, json.loads(output))
        self.assertEqual(output, json.dumps(input))
        self.assertEqual(input, ultrajson.decode(output))

        self.assertEqual('"  \\u0000\\r\\n "', ultrajson.dumps("  \u0000\r\n "))
开发者ID:darthghandi,项目名称:ultrajson,代码行数:14,代码来源:tests.py


示例18: test_encodeUnicode4BytesUTF8

    def test_encodeUnicode4BytesUTF8(self):
        input = "\xf0\x91\x80\xb0TRAILINGNORMAL"
        enc = ultrajson.encode(input)
        dec = ultrajson.decode(enc)

        self.assertEqual(enc, json_unicode(input))
        self.assertEqual(dec, json.loads(enc))
开发者ID:darthghandi,项目名称:ultrajson,代码行数:7,代码来源:tests.py


示例19: test_encodeArrayInArray

    def test_encodeArrayInArray(self):
        input = [[[[]]]]
        output = ultrajson.encode(input)

        self.assertEqual(input, json.loads(output))
        self.assertEqual(output, json.dumps(input))
        self.assertEqual(input, ultrajson.decode(output))
开发者ID:darthghandi,项目名称:ultrajson,代码行数:7,代码来源:tests.py


示例20: test_encodeLongUnsignedConversion

    def test_encodeLongUnsignedConversion(self):
        input = 18446744073709551615
        output = ultrajson.encode(input)

        self.assertEqual(input, json.loads(output))
        self.assertEqual(output, json.dumps(input))
        self.assertEqual(input, ultrajson.decode(output))
开发者ID:darthghandi,项目名称:ultrajson,代码行数:7,代码来源:tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tools.add_env_to_user函数代码示例发布时间:2022-05-27
下一篇:
Python generic.ListView类代码示例发布时间: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