-3

I want to update value of "status" and "amount" Json String

{  
     "installmentno":"1",
     "receiptid":"",
     "duedate":"12-10-2016",
     "paymentdate":"",
     "amount":"3000.00",
     "status":"unpaid"
}

1 Answers1

0

The cleanest way is convert Json to object, change values, and convert again to String Json:

Other methods:

  1. If exists only one occurence of value in Json String, and you know current value, use: String.replace("oldValue", "newValue");

  2. Use String.replaceAll("regex", "newValue"); and regular expression

  3. Use some external library e.g.: https://github.com/stleary/JSON-java.
Hobbajt
  • 267
  • 3
  • 14