21st Century Man Posted December 18, 2024 Posted December 18, 2024 Hi all: I threw together a JSON sandbox file (attached) and looking at one result, I'm not sure if step 18 in the script, Nested Array/Children Records is coded correctly. What that script does is create a field that includes parent and child records between the Grant and District tables. When run, if you look at the JSON field's result, it doesn't (to me) look right--shouldn't the District key be indented as a array or no? The reason why I ask is that when I use the JSONListKeys in the Data Viewer as JSONListKeys ( GRANT::JSON ; "Grant" ), it lists a record count instead of "District," so what am I missing here...or am I just being an absolute numpty? Cheers, Rich JSON Coding.fmp12
comment Posted December 18, 2024 Posted December 18, 2024 (edited) I am not sure what exactly you are asking or what to look at in the attached file. 3 hours ago, Richard Stuart said: shouldn't the District key be indented as a array From what I can see, the JSON in the GRANT::JSON field in the 4th record of your file is properly formatted - at least by the rules that Filemaker uses for formatting JSON (there is no official standard for this and you may see various online formatters return different results). 3 hours ago, Richard Stuart said: when I use the JSONListKeys in the Data Viewer as JSONListKeys ( GRANT::JSON ; "Grant" ), it lists a record count instead of "District," Well, Grant in your JSON is also an array. The keys of any array are the numerical indexes of the array's child elements. The District array is a grandchild of Grant, and you will see it listed if you look at JSONListKeys ( GRANT::JSON ; "Grant[0]" ) or JSONListKeys ( GRANT::JSON ; "Grant[1]" ) and so on. Edited December 18, 2024 by comment 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now