将包含数组的字符串转换为 json 对象
converting a string that contains an array into a json object
在 SOAPUI 中,请求 return 字符串形式的值,无论它们包含什么。
在时间 t 请求 returns 以下字符串:
{satisfied=true, dynamic_href/properties/triggers, name=triggers, value={satisfied=true, dynamic_href/properties/triggers, name=triggers, value=[{type=DAILY, description=null, configuration={allXDays=1, time=08:10:29, timeProgramMode=TIME, startDate=2019-02-28}, id=guid], metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}, metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}
在时间 t+1 相同的请求 returns 以下
{satisfied=true, dynamic_href/properties/triggers, name=triggers, value={satisfied=true, dynamic_href/properties/triggers, name=triggers, value=[{type=DAILY, description=null, configuration={allXDays=1, timeProgramMode=TIME, startDate=2019-02-28, time=08:10:29}, id=guid], metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}, metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}
我必须比较它们以检查没有 属性 改变,但是值数组中的顺序有细微的变化,因此无法直接比较字符串。
当我尝试使用 jsonSlurper 对其进行转换以便逐个元素进行比较时,它会引发错误。
我认为这会帮助我解析我的回复并轻松进行比较。
我试图找到一种方法来解析高级属性(例如 'satisfied'),但也可以解析嵌套属性,例如值或元数据以及更低级别的数组...
编辑
尝试使用 json slurper 进行解析时出现以下错误:
expecting '}' or ',' but got current char 's' with an int value of 115
The current character read is 's' with an int value of 115
expecting '}' or ',' but got current char 's' with an int value of 115
line number 1
index number 1
{satisfied=true, dynamic_href/properties/triggers, name=triggers, value={satisfied=true, dynamic_href/properties/triggers, name=triggers, value=[{type=DAILY, description=mon trigger, configuration={allXDays=1, action=switchOn, time=16:01:02, timeProgramMode=TIME, startDate=2018-04-11}, id=guid], metadata={satisfied=true, href=/m2m/fim/metadata/items/com, hager, domovea, automation, homestatus, HomeStatus/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}, metadata={satisfied=true, href=/m2m/fim/metadata/items/com, hager, domovea, automation, homestatus, HomeStatus/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}
.^
{satisfied=true, dynamic_href/properties/triggers, name=triggers, value={satisfied=true, dynamic_href/properties/triggers, name=triggers, value=[{type=DAILY, description=null, configuration={allXDays=1, timeProgramMode=TIME, startDate=2019-02-28, time=08:10:29}, id=guid], metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}, metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}
该字符串中有不匹配的大括号。有6个{
和5个}
。解析器无法处理。
编辑
2 其他问题是密钥未被引用并且有 =
应该有 :
。还有像 ... , dynamic_href/properties/triggers, ...
这样的东西是无效的 JSON.
在 SOAPUI 中,请求 return 字符串形式的值,无论它们包含什么。 在时间 t 请求 returns 以下字符串:
{satisfied=true, dynamic_href/properties/triggers, name=triggers, value={satisfied=true, dynamic_href/properties/triggers, name=triggers, value=[{type=DAILY, description=null, configuration={allXDays=1, time=08:10:29, timeProgramMode=TIME, startDate=2019-02-28}, id=guid], metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}, metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}
在时间 t+1 相同的请求 returns 以下
{satisfied=true, dynamic_href/properties/triggers, name=triggers, value={satisfied=true, dynamic_href/properties/triggers, name=triggers, value=[{type=DAILY, description=null, configuration={allXDays=1, timeProgramMode=TIME, startDate=2019-02-28, time=08:10:29}, id=guid], metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}, metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}
我必须比较它们以检查没有 属性 改变,但是值数组中的顺序有细微的变化,因此无法直接比较字符串。 当我尝试使用 jsonSlurper 对其进行转换以便逐个元素进行比较时,它会引发错误。 我认为这会帮助我解析我的回复并轻松进行比较。
我试图找到一种方法来解析高级属性(例如 'satisfied'),但也可以解析嵌套属性,例如值或元数据以及更低级别的数组...
编辑
尝试使用 json slurper 进行解析时出现以下错误:
expecting '}' or ',' but got current char 's' with an int value of 115
The current character read is 's' with an int value of 115
expecting '}' or ',' but got current char 's' with an int value of 115
line number 1
index number 1
{satisfied=true, dynamic_href/properties/triggers, name=triggers, value={satisfied=true, dynamic_href/properties/triggers, name=triggers, value=[{type=DAILY, description=mon trigger, configuration={allXDays=1, action=switchOn, time=16:01:02, timeProgramMode=TIME, startDate=2018-04-11}, id=guid], metadata={satisfied=true, href=/m2m/fim/metadata/items/com, hager, domovea, automation, homestatus, HomeStatus/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}, metadata={satisfied=true, href=/m2m/fim/metadata/items/com, hager, domovea, automation, homestatus, HomeStatus/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}
.^
{satisfied=true, dynamic_href/properties/triggers, name=triggers, value={satisfied=true, dynamic_href/properties/triggers, name=triggers, value=[{type=DAILY, description=null, configuration={allXDays=1, timeProgramMode=TIME, startDate=2019-02-28, time=08:10:29}, id=guid], metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}, metadata={satisfied=true, href=/m2m/fim/metadata/items/com.hager.domovea.automation.sequence.Sequence/properties/triggers, name=null, description=null, type=null, classes=null, regex=null, min=null, max=null, step=null, enumeration=null, beanMetadata=null, readable=null, writable=null, eventable=null, asyncStatusPropertyName=null, attributes=null}, asyncStatusProperty=null}
该字符串中有不匹配的大括号。有6个{
和5个}
。解析器无法处理。
编辑
2 其他问题是密钥未被引用并且有 =
应该有 :
。还有像 ... , dynamic_href/properties/triggers, ...
这样的东西是无效的 JSON.