Em có bài toán: Làm sao để cập nhật trường trong 1 noteArray của 1 file Json trong java ạ, đầu vào:
{ "id": "001", "address": [ { "address": "address1" } ] }
đầu ra:
{ "id": "001", "address": [ { "address": "address2" } ] }
We want to connect the people who have knowledge to the people who need it, to bring together people with different perspectives so they can understand each other better, and to empower everyone to share their knowledge.
Em có bài toán: Làm sao để cập nhật trường trong 1 noteArray của 1 file Json trong java ạ, đầu vào:
{ "id": "001", "address": [ { "address": "address1" } ] }
đầu ra:
{ "id": "001", "address": [ { "address": "address2" } ] }
public final class ReplaceJsonValueExample { public static void main(String[] args) throws Exception { final String input = "{\n" + " "id": "001",\n" + " "address": [\n" + " {\n" + " "address": "address1"\n" + " }\n" + " ]\n" + '}'; final ObjectMapper objectMapper = new ObjectMapper(); final Map map = objectMapper.readValue(input, Map.class); ((List<Map>)map.get("address")).get(0).put("address", "address2"); final String output = objectMapper.writeValueAsString(map); System.out.println(output); } }
Input your email to receive reset password link, or if you remember your password, you can click