本文整理汇总了Python中devicehive.dhjson.Parser类的典型用法代码示例。如果您正苦于以下问题:Python Parser类的具体用法?Python Parser怎么用?Python Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_complex
def test_complex(self):
p = Parser(""" { id:'03684ca0-6dee-46d2-98b7-06f2cd079f5c',
key:'5b2e34b4-995a-4d66-8b0f-392232bc1563',
name:'Arduino Pins',
deviceClass:{
name:'Arduino',
version:'1.0'},
equipment:[],
commands:[
{intent:1001,name:'getPinMode',params:[u8]},
{intent:1002,name:'setPinMode',params:{pin:u8,mode:u8}},
{intent:1003,name:'pinRead',params:[u8]},
{intent:1004,name:'pinWrite',params:{pin:u8,value:u16}}
],
notifications:[
{intent:2001,name:'pinMode',params:{pin:u8,mode:u8}},
{intent:2003,name:'pinRead',params:{pin:u8,value:u16}}
]
}""")
self.assertIsNotNone(p.parse())
示例2: test_simple_object_2
def test_simple_object_2(self):
p = Parser("""{"hello":1, '123': 0x123 ,_test: "test"}""")
self.assertEquals({'hello':1, '123': 0x123, '_test': 'test'}, p.parse())
示例3: test_simple_object_1
def test_simple_object_1(self):
p = Parser('{"hello":1}')
self.assertEquals({'hello':1}, p.parse())
示例4: test_mixed_array
def test_mixed_array(self):
p = Parser('["test", 1, hello]')
self.assertEquals(['test', 1, 'hello'], p.parse())
示例5: test_empty_array_1
def test_empty_array_1(self):
p = Parser('[ ]')
self.assertEquals([], p.parse())
示例6: test_simple_array_2
def test_simple_array_2(self):
p = Parser('[1 , 2 , 3,4 , 5,6 ]')
self.assertEquals([1,2,3,4,5,6], p.parse())
示例7: test_esc_3
def test_esc_3(self):
p = Parser(r'"\\""')
self.assertEquals('\\', p.parse())
示例8: test_empty_2
def test_empty_2(self):
p = Parser(' ')
self.assertIsNone(p.parse())
示例9: test_parse_number_8
def test_parse_number_8(self):
p = Parser('0')
self.assertEquals(0, p.parse())
示例10: test_parse_number_16
def test_parse_number_16(self):
p = Parser('0x123')
self.assertEquals(0x123, p.parse())
示例11: test_parse_number_10
def test_parse_number_10(self):
p = Parser('123')
self.assertEquals(123, p.parse())
示例12: test_string_dq_and_space
def test_string_dq_and_space(self):
p = Parser(' "hello all" ')
self.assertEquals('hello all', p.parse())
示例13: test_string
def test_string(self):
p = Parser("'hello all'")
self.assertEquals('hello all', p.parse())
示例14: test_simple_complex_1
def test_simple_complex_1(self):
p = Parser("""{"arr": [ 1, 2 , 3], 'obj': { prop : 1 }}""")
self.assertEquals({'arr':[1,2,3], 'obj': {'prop': 1}}, p.parse())
示例15: test_parse_identifier_2
def test_parse_identifier_2(self):
p = Parser('__test123_321')
self.assertEquals('__test123_321', p.parse())