ChoETL
ChoETL copied to clipboard
Complex JSON path not supported
Hello,
I tried to parse a Json with this content:
{ "fruit":[ { "name":"Apple", "binomial name":"Malus domestica", "major_producers":[ "China", "United States", "Turkey" ], "nutrition":{ "carbohydrates":"13.81g", "fat":"0.17g", "protein":"0.26g" } }, { "name":"Orange", "binomial name":"Citrus x sinensis", "major_producers":[ "Brazil", "United States", "India" ], "nutrition":{ "carbohydrates":"11.75g", "fat":"0.12g", "protein":"0.94g" } } ] }
When using
using (var data = ChoJSONReader.LoadText(inputText: strJsonText).WithJSONPath("$..fruit[*]")) {
An exception is thrown
See https://github.com/Cinchoo/ChoETL/blob/master/src/ChoETL.JSON/ChoJSONRecordReader.cs During reading, IsSimpleJSONPath is called, which calls IsValidIdentifier which returns falls for "fruit[*]"
This does confuse me, because samples in the internet do work with this JsonPath and without this error. Plus, I dont see, how this would indicate a complex JsonPath
It is by design, Cinchoo ETL has its own jpath parsing to handle simple json path (nodes separated by .) only. Main purpose it to handle large JSON files. Complex jsonpath relies on Newtonsoft parser.