-1

JSON object :

{
  "test1":"2",
  "test2":"4",
  "test3":"5"
}

I need to replace "test2":"4" with "test2":"this is test".

How can I do this with Java?

Sga
  • 3,608
  • 2
  • 36
  • 47
coolD
  • 79
  • 1
  • 10

2 Answers2

0

I need to replace "test2":"4" by "this is test" string.

How can I do this with java?.

Using String API, for example with String::replace, remembering:

Community
  • 1
  • 1
Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109
0

If you want to replace string "test2":"4" with "this is test" then it will make your json unparsable and if you want to change the content to the key "test2" from "4" to "this is test" then you can use JSON parser apis like gson or jackson etc.

Imrank
  • 1,009
  • 5
  • 15