skip to Main Content

How can I make \u be u in generated JSON?

public void run(String... args) throws Exception { final ObjectMapper jackson = new ObjectMapper(); final ObjectNode objectNode = jackson.createObjectNode(); String text = "Simplified Chinese 简体中文"; final String escapedInUnicodeText = StringEscapeUtils.escapeJava(text); System.out.println(escapedInUnicodeText); //output is: Simplified Chinese u7B80u4F53u4E2Du6587 objectNode.put("text", escapedInUnicodeText); System.out.println(jackson.writeValueAsString(objectNode)); //output is…

VIEW QUESTION

Json – Why LocalDateTime is serialized as array when return as ReponseBody in springboot?

I want to get the dates in a format of dd/MM/yyyy so,I wrote this code first: @GetMapping("/testAjax.json") public ResponseBody<?> AjaxResponse testAjax(){ AjaxResponse response = new AjaxResponse(); DateTimeTest test = new DateTimeTest(); test.setDateTime(LocalDateTime.now()); response.addResponse("date", LocalDateTime.now()); response.addResponse("test", test); return response; }` and…

VIEW QUESTION

Json – Convert String (Array) to List<Map<Stirng, Object>>

I have the following String. respData = "[{"pmtInd":"C"},{"pmtInd":"D"},{"pmtInd":"G"},{"pmtInd":"C"},{"pmtInd":"B"}]" I am trying to convert this into a List<Map<String, Object>>. However, I get some failures. Here are some things I have tried. List<Map<String, Object>> walletDetailsList = new ArrayList<>(); try { ObjectMapper objectMapper…

VIEW QUESTION

remove backslashes from JSON string

I have a object of type: RestConsumerRequest<RewardsAccumulationRequest> which has @JsonProperty annotated fields like: @JsonProperty("product_code") private String productCode; @JsonProperty("sub_product_code") private String subProductCode; when I wrote it as String using: LOG.info("RestConsumerRequest<RewardsAccumulationRequest> is {}", objectMapper.writeValueAsString(restRequest)) I got: ..., "product_code":"CSS","sub_product_code":"SC",... I tried removing the…

VIEW QUESTION
Back To Top
Search