Search a JSON array using database _id returned from REST
Hi
I think I am making a very simple error around data types - hope someone can help me tell how to convert this data to make my JSON search work
The concept is that I have a database REST service and I want users to be able to set the items and order as a subset using local storage
I have a localStorage which is turned into JSON:
{"5343197ae4b07b0d8015f66f":{"Order":1},"534319aee4b013c661e5e61f":{"Order":1}}
I am creating a local SQLite table that will only write to the table once the 'order is resolved' from the localStorage
The code is
var myList = localStorage.getItem('localOrder');
jmylist =JSON.parse(myList);
item = value._id;
var itemOrder = (jmylist[item].Order);
It returns
TypeError: 'undefined' is not an object (evaluating 'jmylist[item].Order')
If I use the following in a console it works
var itemOrder = (jmylist["5343197ae4b07b0d8015f66f"].Order);
I realise the type of the object is wrong - what do I have to do to make it work?