How to change values in a json file using XPath/JsonPath in java
here is the json file
{
"session":
{
"name":"JSESSIONID",
"value":"5864FD56A1F84D5B0233E641B5D63B52"
},
"loginInfo":
{
"loginCount":77,
"previousLoginTime":"2014-12-02T11:11:58.561+0530"
}
}
I want to change the value of name.by directly giving XPath/JsonPath Like
($.session.name).changevalue("MYSESSINID")
this is just a Example
I am correctly using jackson library and using the below code for reading via XPath
ObjectMapper mapper = new ObjectMapper();
Object jsonObj=mapper.readValue(new File(Json file), Object.class);
Object name=PropertyUtils.getProperty(jsonObj, "session.name");
System.out.println("Name:"+name);
so is their a way to change the name by XPath
PropertyUtils.setProperty(jsonObj, "session.value", "new value");
still in the file its not working.