Search code examples
nativescript

Javascript Array with Double Quotes


I'm using Nativescript Http.getString to get a list of dates from a web service.

The Web service returns a string as expected which I then want to use in a Javascript Array.

The String is "'31/08/2021','24/12/2021','25/12/2021','26/12/2021','27/12/2021','28/12/2021','29/12/2021','30/12/2021','31/12/2021','01/01/2022','01/04/2022','04/04/2022'" or similar, the dates will change over time.

But I want to have a Javascript DateArray = ['31/08/2021','24/12/2021','25/12/2021','26/12/2021','27/12/2021','28/12/2021','29/12/2021','30/12/2021','31/12/2021','01/01/2022','01/04/2022','04/04/2022'] so removing the double quotes before using in the array.

I cannot find a way to remove the double quotes and apply the result to the Javascript Array.


Solution

  • Ok so I've rewritten to output JSON then parse the JSON output to a Javascript Array. Much easier to do and handle rather than a string output.