我正在使用jsonPath来访问json字符串的值。使用json路径我得到一个值列表,我必须修改它们并再次将它们设置回相应的位置。当我尝试这样做时,Jsonpath设置所有位置的所有值。我想在正确的位置找到正确的值。怎么做?
我正在使用jsonpath:“employees [*]。name”并使用DocumentContext.set("employees[*].name", List<String> values);
JSON:
{
"employees" : [ {
"name" : "Rama",
"email" : "ram@gmail.com",
"age" : 23
}, {
"name" : "Shya",
"email" : "shyam23@gmail.com",
"age" : 28
}, {
"name" : "John",
"email" : "john@gmail.com",
"age" : 33
}, {
"name" : "Boby",
"email" : "bob32@gmail.com",
"age" : 41
} ]
}
WHAT I AM GETTING:
{
"employees" : [ {
"name" : "[1aRama,3jShya,j5John,ytBoby]",
"email" : "ram@gmail.com",
"age" : 23
}, {
"name" : "[1aRama,3jShya,j5John,ytBoby]",
"email" : "shyam23@gmail.com",
"age" : 28
}, {
"name" : "[1aRama,3jShya,j5John,ytBoby]",
"email" : "john@gmail.com",
"age" : 33
}, {
"name" : "[1aRama,3jShya,j5John,ytBoby]",
"email" : "bob32@gmail.com",
"age" : 41
} ]
}
WHAT I WANT:
{
"employees" : [ {
"name" : "1aRama",
"email" : "ram@gmail.com",
"age" : 23
}, {
"name" : "3jShya",
"email" : "shyam23@gmail.com",
"age" : 28
}, {
"name" : "j5John",
"email" : "john@gmail.com",
"age" : 33
}, {
"name" : "ytBoby",
"email" : "bob32@gmail.com",
"age" : 41
} ]
}