我在Ruby中面临有关JSON处理的问题。我有一个字符串str1
,几分钟后它变为str2
:
str1 =
'{ "Person1": { "state": [ {"salery": "100", "time": "100"} ],
"temp": [{"age": "12","time": "200" }] },
"person2": { "state": [ {"salery": "12","time": "120"}],
"temp": [ {"age": "12","time": "220"}]}
}'
更改为:
str1 =
'{
"Person1": { "state": [ {"salery": "changed", "time": "100"} ],
"temp": [{"age": "12","time": "200" }] },
"person2": { "state": [ {"salery": "12","time": "120"}],
"temp": [ {"age": "12","time": "220"}]}
}'
根据此更改,我只需要输出更改行,因为这里只有str1行 - > str2已更改({"salery": "100" -> "salery": "changed")
。
输出:
{
"Person1": { "state": [ { "salery": "changed","time": "100"} ] }
}