httpBuilder JSON响应解析包含[]

时间:2017-10-03 07:48:34

标签: json dictionary groovy httpbuilder

这可能非常明显所以请保持温和。

以下代码:

[objects:[[uid:892d08fb-0dca-5146-8587-49fa07ece24c, name:gw-6eee89, type:simple-gateway, domain:[uid:41e821a0-3720-11e3-aa6e-0800200c9fde, name:SMC User, domain-type:domain]]], from:1, to:1, total:1]

POST Success. SHOWGWS: HTTP/1.1 200 OK

[gw-6eee89]

4

class groovy.json.internal.LazyMap

Caught: Assertion failed: 

   assert json.objects.name == 'gw-6eee89'
       |    |       |    |
       |    |       |    false
       |    |       [gw-6eee89]
       |    [[uid:892d08fb-0dca-5146-8587-49fa07ece24c, name:gw-6eee89, type:simple-gateway, domain:[uid:41e821a0-3720-11e3-aa6e-0800200c9fde, name:SMC User, domain-type:domain]]]
       [objects:[[uid:892d08fb-0dca-5146-8587-49fa07ece24c, name:gw-6eee89, type:simple-gateway, domain:[uid:41e821a0-3720-11e3-aa6e-0800200c9fde, name:SMC User, domain-type:domain]]], from:1, to:1, total:1]

给出以下输出:

 SET i /o1*o7/;
 ALIAS(i,ii);
 EQUATION EqName1(i), EqName2(i);
 EqName1(i)$(ord(i) lt 4)..      SUM(ii$((ord(ii) ge ord(i)) AND (ord(ii) le (ord(i)+5))),value(ii) =g= 5*value(i)
 EqName2(i)$(ord(i) ge 4)..      SUM(ii,value(ii)) + SUM(ii$(ord(ii) le (ord(i) - 3)),value(ii)) =g= 5*value(i)

似乎是将gw-6eee89与[gw-6eee89]

进行比较

我无法理解为什么在调用值时不会删除方括号。任何帮助非常感谢。

1 个答案:

答案 0 :(得分:1)

由于objectsList的实例,如果您致电list.someProperty,您将获得列表中所有对象的someProperty值列表:

[[name:1],[name:2]].name == [1, 2]

您需要获取第一个对象。例如:objects.name[0]