本文整理汇总了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}
示例2: testReadDictWithSlashStarComments
def testReadDictWithSlashStarComments(self):
s = """
{'a':false, /*don't want b
b:true, */
'c':true
}
"""
assert json.read(s) == {'a':False,'c':True}
示例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)
示例4: testReadDictOfListsWithSpaces
def testReadDictOfListsWithSpaces(self):
s = u"{ 'a' : [], 'b' : [] } "
assert json.read(s) == {'a':[],'b':[]}
示例5: testReadEFloat2
def testReadEFloat2(self):
s = u"1.334E-02"
assert json.read(s) == 0.01334
示例6: testReadNegInt
def testReadNegInt(self):
s = u"-1"
assert json.read(s) == -1
示例7: testReadInt
def testReadInt(self):
s = u"1"
self.assertEqual(json.read(s), 1)
示例8: testReadString
def testReadString(self):
s = u"'hello'"
self.assertEqual(json.read(s) ,'hello')
示例9: testUnicodeFromNonUnicode
def testUnicodeFromNonUnicode(self):
obj = "'\u20ac'"
r = json.read(obj)
self.assertEqual(r, u'\u20ac')
示例10: readUBadJson
def readUBadJson(self):
s = ur"\u0027DOS\u0027*30"
json.read(s)
示例11: testReadStringWithEscapedSingleQuote
def testReadStringWithEscapedSingleQuote(self):
s = '"don\'t tread on me."'
assert json.read(s) == "don't tread on me."
示例12: testReadStringWithWhiteSpace
def testReadStringWithWhiteSpace(self):
s = ur"'hello \tworld'"
assert json.read(s) == 'hello \tworld'
示例13: testReadListOfStringsWithSpaces
def testReadListOfStringsWithSpaces(self):
s = u" ['a' ,'b' ,\n 'c'] "
assert json.read(s) == ['a','b','c']
示例14: testReadListOfDictsWithSpaces
def testReadListOfDictsWithSpaces(self):
s = u" [ { } ,{ \n} ] "
assert json.read(s) == [{},{}]
示例15: testReadListOfDicts
def testReadListOfDicts(self):
s = u"[{},{}]"
assert json.read(s) == [{},{}]