JSON arrays
I'm trying to read the following JSON:
The ECL record structure I would think I need is:
However if I try parsing that using FROMJSON I get my record contains a level1_field1 which in turn appears to contain a record named Item and which contains no data ( ). Does anyone know a way round this or do I need to create a JIRA?
- Code: Select all
{
"level1_field1":[
"level1_value1",
"level2_value2"
]
}
The ECL record structure I would think I need is:
- Code: Select all
ResultData := RECORD
SET OF UTF8 level1_field1;
END;
However if I try parsing that using FROMJSON I get my record contains a level1_field1 which in turn appears to contain a record named Item and which contains no data ( ). Does anyone know a way round this or do I need to create a JIRA?
- james.wilson
- Posts: 25
- Joined: Fri Nov 14, 2014 3:44 pm
Aha! A colleague has helped me out with this, it works correctly if the field has an XPATH:
So TL;DR is always, always have XPATHs for all fields when parsing JSON (which will also get round annoying case issues as if there's no XPATH then HPCC will use a lowercased version of the field name).
- Code: Select all
ResultData := RECORD
SET OF UTF8 level1_field1 {XPATH('level1_field1')};
END;
So TL;DR is always, always have XPATHs for all fields when parsing JSON (which will also get round annoying case issues as if there's no XPATH then HPCC will use a lowercased version of the field name).
- james.wilson
- Posts: 25
- Joined: Fri Nov 14, 2014 3:44 pm
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest