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


Python minjson.read函数代码示例

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


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

示例1: testReadDictWithDoubleSlashComments

 def testReadDictWithDoubleSlashComments(self):
     s = """
     {'a':false,
       //  b:true, don't want b
     'c':true
     }
     """
     assert json.read(s) == {'a':False,'c':True}
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:8,代码来源:tests.py

示例2: testReadDictWithSlashStarComments

 def testReadDictWithSlashStarComments(self):
     s = """
     {'a':false,  /*don't want b
         b:true, */
     'c':true
     }
     """
     assert json.read(s) == {'a':False,'c':True}
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:8,代码来源:tests.py

示例3: read

 def read(self, aString, encoding=None):
     if hasCJson:
         try:
             # the True parameter here tells cjson to make all strings 
             # unicode. This is a good idea here.
             return cjson.decode(aString, True)
         except cjson.DecodeError:
             # fall back to minjson
             pass
     # This is a fall-back position for less-well-constructed JSON
     try:
         return minjson.read(aString, encoding)
     except minjson.ReadException, e:
         raise exceptions.ResponseError(e)
开发者ID:jean,项目名称:z3c.json,代码行数:14,代码来源:converter.py

示例4: testReadDictOfListsWithSpaces

 def testReadDictOfListsWithSpaces(self):
     s = u"{  'a' :    [],  'b'  : []  }    "
     assert json.read(s) == {'a':[],'b':[]}
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例5: testReadEFloat2

 def testReadEFloat2(self):
     s = u"1.334E-02"
     assert json.read(s) == 0.01334
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例6: testReadNegInt

 def testReadNegInt(self):
     s = u"-1"
     assert json.read(s) == -1
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例7: testReadInt

 def testReadInt(self):
     s = u"1"
     self.assertEqual(json.read(s), 1)
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例8: testReadString

 def testReadString(self):
     s = u"'hello'"
     self.assertEqual(json.read(s) ,'hello')
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例9: testUnicodeFromNonUnicode

 def testUnicodeFromNonUnicode(self):
     obj = "'\u20ac'"
     r = json.read(obj)
     self.assertEqual(r, u'\u20ac')
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:4,代码来源:tests.py

示例10: readUBadJson

 def readUBadJson(self):
     s = ur"\u0027DOS\u0027*30"
     json.read(s)
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例11: testReadStringWithEscapedSingleQuote

 def testReadStringWithEscapedSingleQuote(self):
     s = '"don\'t tread on me."'
     assert json.read(s) == "don't tread on me."
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例12: testReadStringWithWhiteSpace

 def testReadStringWithWhiteSpace(self):
     s = ur"'hello \tworld'"
     assert json.read(s) == 'hello \tworld'
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例13: testReadListOfStringsWithSpaces

 def testReadListOfStringsWithSpaces(self):
     s = u" ['a'    ,'b'  ,\n  'c']  "
     assert json.read(s) == ['a','b','c']
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例14: testReadListOfDictsWithSpaces

 def testReadListOfDictsWithSpaces(self):
     s = u" [ {    } ,{   \n} ]   "
     assert json.read(s) == [{},{}]
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py

示例15: testReadListOfDicts

 def testReadListOfDicts(self):
     s = u"[{},{}]"
     assert json.read(s) == [{},{}]
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


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