0

I'm trying to parse a JSON string into a Map using ObjectMapper. To achieve this, I used this simple code below.

ObjectMapper objectMapper = new ObjectMapper(); Map value = objectMapper.readValue((String) mainJsonValueMap, Map.class); 

The code runs without any error, and all the property keys are visible in the created map; but some of the values are truncated.

In this example, I used the JSON string below:

{ "Vmax": null, "Pictures": "[{\"code\":\"603442f0-2e92-406a-a25c-4c090b750d01:1.0\",\"filename\":\"test-file (2).jpeg\",\"content\":null}]", "2D&3D files": null, "logical_match": null, "Certifications": null, "Geographic_area": "EU", "US_price_factor": 1.58, "Technical documents": "{\"deu\":[{\"code\":\"fdceed2a-9703-4186-b7a0-101e6d82eec6:2.0\",\"filename\":\"project_gobo_c210_slice_integral_assembly instruction_de_it_en.pdf\",\"content\":\"\"},{\"code\":\"d729a7f2-e782-4c71-8ee1-97f22d8d5659:1.0\",\"filename\":\"project_chameleon_c210 slice_gobo_datenblatt_de.pdf\",\"content\":\"\"}],\"ita\":[{\"code\":\"fdceed2a-9703-4186-b7a0-101e6d82eec6:1.0\",\"filename\":\"project_gobo_c210_slice_integral_assembly instruction_de_it_en.pdf\",\"content\":\"\"},{\"code\":\"ccb9cf28-53bc-45f9-868d-b3d29bdf79bd:1.0\",\"filename\":\"project_chameleon_c210 slice_gobo_scheda tecnica_it.pdf\",\"content\":\"\"},{\"code\":\"dad959ce-95b5-4d8d-b524-1a43cd623c8f:1.0\",\"filename\":\"test-file2.json\",\"content\":null}],\"fr\":[{\"code\":\"1f6a7ca9-b816-444d-8f32-1a0b3363e834:1.0\",\"filename\":\"project_gobo_c210_slice_integral_instructions de montage_fr.pdf\",\"content\":\"\"},{\"code\":\"52e50fb1-4e03-42b7-96b5-3e7a8e651848:1.0\",\"filename\":\"project_chameleon_c210 slice_gobo_fiche technique_fr.pdf\",\"content\":\"\"}],\"eng\":[{\"code\":\"fdceed2a-9703-4186-b7a0-101e6d82eec6:3.0\",\"filename\":\"project_gobo_c210_slice_integral_assembly instruction_de_it_en.pdf\",\"content\":\"\"},{\"code\":\"3d3c82ab-c0cb-4f66-bf68-cde6d1c43519:1.0\",\"filename\":\"project_chameleon_c210 slice_gobo_datasheet_en.pdf\",\"content\":\"\"},{\"code\":\"0b8fccce-fc88-47e9-9837-f44b6dfc9ed3:1.0\",\"filename\":\"00logo2.png\",\"content\":\"\"}]}", "Configurator picture": "{\"code\":\"e29ac4ef-1a3f-4dc0-9c4e-0181543dd5fd:1.0\",\"filename\":\"test-file (1).jpeg\",\"content\":null}", "current_max_with_RBL": null, "lens_block_image_file": null, "luminaire_installation": null, "ball proof certification": false } 

But for the property Technical documents, ObjectMapper generates the string below. Which as you can see it's being cut in the middle.

{"deu":[{"code":"fdceed2a-9703-4186-b7a0-101e6d82eec6:2.0","filename":"project_gobo_c210_slice_integral_assembly instruction_de_it_en.pdf","content":""},{"code":"d729a7f2-e782-4c71-8ee1-97f22d8d5659:1.0","filename":"project_chameleon_c210 slice_gobo_datenblatt_de.pdf","content":""}],"ita":[{"code":"fdceed2a-9703-4186-b7a0-101e6d82eec6:1.0","filename":"project_gobo_c210_slice_integral_assembly instruction_de_it_en.pdf","content":""},{"code":"ccb9cf28-53bc-45f9-868d-b3d29bdf79bd:1.0","filename":"project_chameleon_c210 slice_gobo_scheda tecnica_it.pdf","content":""},{"code":"dad959ce-95b5-4d8d-b524-1a43cd623c8f:1.0","filename":"test-file2.json","content":null}],"fr":[{"code":"1f6a7ca9-b816-444d-8f32-1a0b3363e834:1.0","filename":"project_gobo_c210_slice_integral_instructions de montage_fr.pdf","content":""},{"code":"52e50fb1-4e03-42b7-96b5-3e7a8e651848:1.0","filename":"project_chameleon_c210 slice_gobo_fiche technique_fr.pdf","content":""}],"eng":[{"code":"fdceed2a-9703-4186-b7a0-101e6d82eec6:3.0","filename":"project_gobo 

I assumed there was a problem with my JSON string, but when I validated it with JSONLint it seemed fine. Can anyone help me fix this issue?

Note: Values staying as String is fine for me. I just want to get the whole string without truncation.

7
  • The values for Pictures, Technical documents, and Configurator picture are all strings. They are escaped JSON values. You will need to probably write your own value deserializer for those fields. Commented Dec 2, 2024 at 17:08
  • I want to get these values as string, there is no problem in that matter. Commented Dec 2, 2024 at 17:38
  • 1
    @bro Where did you get that truncated string from? Are you sure that it is really truncated? The way you are posting this, there is not even a closing quote (") at the end of the string. For me, this looks like you've taken this out of some kind of JSON tool, debugger, or similar, where the GUI needs to cut what is shown on the screen for visibility reasons. This doesn't mean the actual value is truncated. There is no reason for a parser to cut a string value at a random position, if it is able to parse the complete JSON. (And if it weren't there would have been a parsing error.) Commented Dec 2, 2024 at 17:41
  • I got the truncated string from the debugger tool of IntellliJ (“Evaluate expression” button or the section where we can see the variables). Now, you said that, I will try to print the map and see it again. Commented Dec 2, 2024 at 17:42
  • Seems to be a limitation of the IntelliJ "Evaluate expression" output (although I cannot reproduce it in IntelliJ 2024.3). Did you try to get the length of that string (by casting to a String and adding .length())? Commented Dec 2, 2024 at 17:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.