Question about ExtractJSONxyz() into a struktured taget

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 674
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

Question about ExtractJSONxyz() into a struktured taget

Post by Kurzer »

Hello Fred,

is there a reason why the ExtractJSONxyz() commands require the names(!) of the target structure to match the names(!) of the JSON structure?
The help only says that the types of the structure fields must match, not the names.

If you take the example ExtractJSONList() and rename the structure fields x and y to a and b (also in the debug line), the JSON data will no longer be extracted.
https://www.purebasic.com/documentation ... nlist.html

This affects PureBasic and SpiderBasic.

Markus
PB 6.12 x64, OS: Win 11 24H2 x64, Desktopscaling: 150%, CPU: I7 12700 H, RAM: 32 GB, GPU: Intel(R) Iris(R) Xe Graphics | NVIDIA GeForce RTX 3070, User age in 2025: 57y
"Happiness is a pet." | "Never run a changing system!"
#NULL
Addict
Addict
Posts: 1498
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Question about ExtractJSONxyz() into a struktured taget

Post by #NULL »

I think the order of the properties in a JSON object should not matter (for example see discussion here), so pb can't rely on that order to map to the structure fields.
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 674
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

Re: Question about ExtractJSONxyz() into a struktured taget

Post by Kurzer »

Ah, okay, that really makes sense. Image
Thanks, #Null, for clarify this.
PB 6.12 x64, OS: Win 11 24H2 x64, Desktopscaling: 150%, CPU: I7 12700 H, RAM: 32 GB, GPU: Intel(R) Iris(R) Xe Graphics | NVIDIA GeForce RTX 3070, User age in 2025: 57y
"Happiness is a pet." | "Never run a changing system!"
Post Reply