I have an issue where I have a file which contains my objects in the form
Dog1: {
information: {
color: 'red',
name: 'Tom'
}
}
and I am building a program which automatically populates my object from a file but the current output has the form
"Dog1": {
"information": {
"color": "red",
"name": "Tom"
}
}
My issue is that i need single or double quotes around "red" and "Tom" but i don't need it on everything else. I have tried using jscodeshift but cannot seem to get it working. Anybody got any tips for this?
Thank you very much for your time, Joe
Your object is a JavaScript object right? However the object is written into the file, it seems that it´s written in JSON format (JavaScript Object Notation).
In my opinion, thats not wrong. It´s the correct way to store JavaScript objects. If you really don´t want the the quotes, you maybe need to implement your own logic for writing the object into the file.
Update: See JSON.Stringify without quotes on properties?. That guy had the same problem and the solution was to remove the quotes after calling JSON.stringify().