Javascript - cannot convert complex string to JSON "{champ: '{{'axe' | translate}}', oeil : 'droit', format:'{{'format30' | translate}}' }"

Viewed 30

I tried with JSON.parse() and replacing the quotes also, but it's not working.

let str = "{champ: '{{'axe' | translate}}', oeil : 'droit', format:'{{'format30' | translate}}' }"

I expect the result as below. I need the solution to convert as valid JSON. Not just by doing JSON.parse(str).

{
    champ: "{{'axe' | translate}}",
    oeil: 'droit',
    format: "{{'format30' | translate}}"
}
0 Answers
Related