Aem 6.5 | quotes inside json .. making it invalid json | Community
Skip to main content
Level 2
January 26, 2024
Solved

Aem 6.5 | quotes inside json .. making it invalid json

  • January 26, 2024
  • 2 replies
  • 854 views

In my excel sheet- one of the field is having value - ram and adam are a sensible, They have their weekly "play date."

I am trying to convert excel data into json in my java code. Here below is json

 

{

    "ID": "9.0",

    "Description": "ram and adam  are a sensible,  They have their weekly "play date."",

    "Genre": "Comedy"

}

But if i try to validate this json this is invalid bcoz of “play date” inside value of description field. Bcoz json itself have quotes n braces. What should i do now to create a valid json

I tried some regex but did not work

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by narendragandhi

Hi @sumansatija4 

 

There are multiple recommended way to escape double quotes in JSON. Please refer the below link for the same -

 

https://www.baeldung.com/java-json-escaping

 

Thanks

Narendra

2 replies

narendragandhi
Community Advisor
narendragandhiCommunity AdvisorAccepted solution
Community Advisor
January 29, 2024

Hi @sumansatija4 

 

There are multiple recommended way to escape double quotes in JSON. Please refer the below link for the same -

 

https://www.baeldung.com/java-json-escaping

 

Thanks

Narendra

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 30, 2024

You would need to fix this manually, you can use something like JsonValidator to find for you all the instances the JSON format is breaking. https://jsonformatter.curiousconcept.com/ 

 

Hope this helps.

Esteban Bustamante