Parse a JSON field where the name starts with a number?
I have some JSON that looks like this:
Is it possible to model this in ECL? I can't have a fieldname that starts with a number
But I don't appear to be able to do it with XPATH either, this produces a compilation error too:
Any ways round this?
{
"first_field": "a value",
"2nd_field": "another value"
}
Is it possible to model this in ECL? I can't have a fieldname that starts with a number
MyLayout := RECORD
STRING first_field;
STRING 2nd_field;
END;
But I don't appear to be able to do it with XPATH either, this produces a compilation error too:
MyLayout := RECORD
STRING first_field;
STRING second_field {XPATH('2nd_field')};
END;
Any ways round this?
- james.wilson
- Posts: 25
- Joined: Fri Nov 14, 2014 3:44 pm
James,
Yep, looks like the XPATH parser doesn't like names that start with a number.
My only suggestion is to edit the source JSON text and search/replace all those names by prepending an underscore (i.e. change "2field" to "_2field") and then the parser will be happy.
Otherwise, if this is a common practice in JSON, you need to submit a JIRA to fix the "bug" in the parser.
HTH,
Richard
Yep, looks like the XPATH parser doesn't like names that start with a number.

My only suggestion is to edit the source JSON text and search/replace all those names by prepending an underscore (i.e. change "2field" to "_2field") and then the parser will be happy.
Otherwise, if this is a common practice in JSON, you need to submit a JIRA to fix the "bug" in the parser.
HTH,
Richard
- rtaylor
- Community Advisory Board Member
- Posts: 1619
- Joined: Wed Oct 26, 2011 7:40 pm
Hi Richard
Unfortunately it's not my JSON so I can't change the field names
I've created https://track.hpccsystems.com/browse/HPCC-26969 to see if it can be fixed at some point.
Thanks
James
Unfortunately it's not my JSON so I can't change the field names

I've created https://track.hpccsystems.com/browse/HPCC-26969 to see if it can be fixed at some point.
Thanks
James
- james.wilson
- Posts: 25
- Joined: Fri Nov 14, 2014 3:44 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: Google [Bot] and 1 guest