Search code examples
javascriptknockout.jskogrid

Javascript convert to array


I need to create an array of objects, with each object containing fields "LicenseRefNo", "FPPRNO" etc.

The website makes an ajax call to a C# controller which currently returns the following json:

"[{\"LicenseRefNo\":\"17/00031/HMO\",\"FPPRNO\":\"AGE146\"},{\"LicenseRefNo\":\"16/00031/HMO\",\"FPPRNO\":\"AGE146\"}]"

This seems to be almost correct but I need to set this as a gridOptions.data property of a KOGrid. It seems the javascript code is then running into a problem because the KOGrid needs to be an observable array, and to create one of these I need a javascript array.

How can I convert the string I have into an array please?


Solution

  • JSON.parse(string) should do the trick