JSON members with ":" and other special characters

Just starting out? Need help? Post your questions and find answers here.
boddhi
Enthusiast
Enthusiast
Posts: 208
Joined: Mon Nov 15, 2010 9:53 pm

JSON members with ":" and other special characters

Post by boddhi »

Hello,

I need to retrieve some JSON data from the internet, which contains member names with ":", "#" and "@" like :
"aaaa:bbbb" : "xxxx"
"#cccc" : "yyyy"
"@dddd" : "zzzz"
I want to use ExtractJSONStructure() because I know in advance the JSON data tree, which won't change. This technique would be more practical for me than examining the structure in its entirety.

But how can I manage variable names in a PB structure with this type of JSON member names? Is this even possible?

Thanks for your help.
Fred
Administrator
Administrator
Posts: 16581
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: JSON members with ":" and other special characters

Post by Fred »

It's not yet possible, but I plan to add an optional parameter to specify a specific mapping (using a Map()) as some fields can't be mapped to native types.
User avatar
Kiffi
Addict
Addict
Posts: 1347
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: JSON members with ":" and other special characters

Post by Kiffi »

Fred wrote: Wed May 31, 2023 1:26 pmI plan to add an optional parameter to specify a specific mapping (using a Map()) as some fields can't be mapped to native types.
That would be great! :D
Hygge
boddhi
Enthusiast
Enthusiast
Posts: 208
Joined: Mon Nov 15, 2010 9:53 pm

Re: JSON members with ":" and other special characters

Post by boddhi »

Fred wrote: Wed May 31, 2023 1:26 pm It's not yet possible, but I plan to add an optional parameter to specify a specific mapping (using a Map()) as some fields can't be mapped to native types.
Thank you for your reply and I look forward to seeing this feature available. :wink:
infratec
Always Here
Always Here
Posts: 6810
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: JSON members with ":" and other special characters

Post by infratec »

At the moment I always use ReplaceString() to replace such things in JSON$ before I use ExtractJSONStructure()
boddhi
Enthusiast
Enthusiast
Posts: 208
Joined: Mon Nov 15, 2010 9:53 pm

Re: JSON members with ":" and other special characters

Post by boddhi »

infratec wrote: Wed May 31, 2023 2:47 pm At the moment I always use ReplaceString() to replace such things in JSON$ before I use ExtractJSONStructure()
That's the fallback solution I've opted for. But I didn't want to have to parse the whole JSON structure, if that were possible ;)
Post Reply