-1

So after JSON.stringify an array with object,

I have this result [{"title":"Unavaible","start":"2020-05-19","end":"2020-05-22"}].

But the title, start, end I would like them without with the " " anyone knows how I can remove them somehow?

Michael Kitas
  • 239
  • 1
  • 2
  • 14
  • Is there a way that you could give more background to this task? Where is that file being saved? If saved in a json file, that's a valid key, you can't just remove the double quotation. Please explain more about your situation. – Renan Cidale May 17 '20 at 08:33
  • by default JSON.stringify convert your object to string that contain keys and values, use JSON.parse to convert stringify to original object – barzin.A May 17 '20 at 08:35
  • What would you want to do that? – ABGR May 17 '20 at 08:46
  • @RenanCidale you CAN just remove then double quotation... – Michael Kitas May 17 '20 at 08:49
  • of course you can, you can go and delete manually the key, you can use search and replace in your IDE, you can run .replace if that's a string. But not knowing to what purpose that's being used, everything get's lost. JSON without double quotation is not a valid JSON anymore. – Renan Cidale May 17 '20 at 11:45

1 Answers1

2

I wouldn't recommend it because that is the proper format of JSON, but I found some code from this answer which will do it.

var someStr = 'He said "Hello, my name is Foo"';
console.log(someStr.replace(/['"]+/g, ''));
NintendoZaedus
  • 653
  • 3
  • 8
  • 22