I have been working in FileMaker and C++ so long I am not at all accustomed to caring about spaces. I will look and see why the 2016 is getting formatted with spaces but it looks like that is why I was not able to get it to work.
I am not sure why but JSON is very confusing for me to rap my head around. But the potential is really exciting.
If that is how you get JSON then it sucks at little because you'd expect an array with elements for each year. But as it is, use the JSONListKeys () function to get a list of the years and then loop through that list and ask for the land element of each one of the key's value.
Well right now how I do things are in flux and I am hoping to get guidance on how best to do it.
What I am trying to do as my first attempt at JSON is to have a a graph populated from JSON with some basic information. a list of years and amounts for Land and Improvements for each year. I feel like I am about 70% there on it functioning but about 30% for understanding.
You lost me a little on your last response but it seems like I might not be formatting my original JSON correctly?
With some more research and some trial and error I was able to get it to work I think. Below was the result. Be fore I proceed can you confirm this looks good? If this dose look good I will start working on putting it into a chart. Thank you for all your help you really pointed me in the right direction.
perhaps you missed that part in my pseudo script. The square brackets instead of the curly brackets is what you initiate the array with.
Based on your output you may have used curly brackets; change that to square brackets and you will end up with a proper array.
Well I am glad I continued posting my results and it proves I still have a lot to learn.
If I change $array to "[]" instead of "{}" it looks like this. If this is correct I am not sure how one would reference the different elements? I think that is what they are called.
Your $array is a structure you can read from in a loop by asking for a specific entry in the following fashion to retrieve your json object:
JSONGetElement ( $array ; "[0]" )
JSON arrays are 0 based, so asking for entry 0 gives you the first entry of the array.
You can retrieve individual values from your $array by giving the corresponding path:
JSONGetElement ( $array ; "[4].year" )
The above will retrieve the year for the 5th object in your array.
If you are dealing with a large array, parsing in a loop for different keys using the full path from the root can tax you performance wise. It can be preferable to retrieve the whole array entry in a variable and then parse out other elements from the nested keys referring to your new variable.
Always keep in mind that keys are case-sensitive.
You seem to be on the right path (pun intended).
If anyone else wants to add something I might have missed or correct me, please do so.
I am now able to grab all the data. I mistakenly thought you would need them to be defined to grab 0-4 but it looks like it works without. Thank you @Bobino for that explanation. I will play around with this some more and probably come back with question on how best to put this data into a chart. But this gives me a lot to work with for now.
If you wish to check JSon data, use http://jsonviewer.stack.hu/ which is a JSon Viewer: on the Text Tab type/paste the JSon Data and the switch to the Viewer Tab to see what you get. Errors are flagged !