Copy link to clipboard
Copied
So I am trying to convert my JSON into a cfquery object to use it in my application.
Here is what my JSON looks like. Its a structure containing an array of structures.
But when I look at other CF posts on this topic I see the JSON data looks like this.
A Structure of Arrays. Which there is a lot of documentation on how to work within cf.
QUESTION: How do I get my deserialized JSON file to be a Structure of Arrays instead of a structure containing an array of structures
I'm sorry.. been a while since I tried any of this, and the flag is actually FALSE, not true.
If Strictmapping is set to false and the JSON object was created from a CF query object, then DeserializeJSON() will automatically convert the JSON to a CF query object.
SO, create a query object from scratch, SerializeJSON() it, then stringify it (I know how in JavaScript, not CF) and look at the f
...Copy link to clipboard
Copied
It depends upon how it was created.
If the JSON object was created from a CF query object, and if a certain flag was set to 'true', then it's just a matter of deserializing it back into a query object.
If, however, it was not done with the true flag, or if it was created from a source other than CF (like a third-party API), then check the stringified format of the JSON object and compare it to the stringified format of a JSON object created by CF with the true flag set, and manually edit the other one to match. Then you could convert it back into a query object.
I know that's not exactly the answer you were looking for, but just something to consider.
V/r,
^ _ ^
Copy link to clipboard
Copied
Thank you, Wolf. This JSON was created by a Google API. I'll try what you suggest. Any idea where I can get a stringified format of a JSON object created by CF with the true flag set?
Copy link to clipboard
Copied
I'm sorry.. been a while since I tried any of this, and the flag is actually FALSE, not true.
If Strictmapping is set to false and the JSON object was created from a CF query object, then DeserializeJSON() will automatically convert the JSON to a CF query object.
SO, create a query object from scratch, SerializeJSON() it, then stringify it (I know how in JavaScript, not CF) and look at the format. If the format of the API JSON string doesn't match, you can take that string and programmatically edit it to match what the CF version is. CF will then convert the JSON into a CF query object. I've done it once, but that was about five years ago, and I'm not currently recalling much detail from that project.
HTH,
^ _ ^
Copy link to clipboard
Copied
Thanks for marking my answer as correct. I do appreciate it.
So this did what you were looking for? How'd it go?
V/r,
^ _ ^