Exception while accessing into flattened json object
See original GitHub issueI’m trying to access flattened json object by using json path:
using ChoETL;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
typeof(ChoJSONReader).GetAssemblyVersion().Print();
"".Print();
string json = @"{
""BrandId"": ""998877665544332211"",
""Categories"": [ ""112233445566778899"" ],
""Contact"": {
""Phone"": [
{
""Value"": ""12346789"",
""Description"": { ""vi"": ""Phone"" },
""Type"": 1
}
]
}
}";
using (var r = ChoJSONReader.LoadText(json)
.Configure(c => c.DefaultArrayHandling = false)
.Configure(c => c.FlattenNode = true)
.Configure(c => c.UseNestedKeyFormat = true)
.Configure(c => c.FlattenByNodeName = "Contact.Phone")
.Configure(c => c.NestedKeySeparator = '.')
.Configure(c => c.NestedColumnSeparator = '.')
)
{
//var dt = r.AsDataTable();
//dt.DumpAsJson().Print();
var a = r.WithField("Phone","$.[\"Contact.Phone.Value\"]");
a.Print();
}
}
}
After running this code, it’s return this output:
ChoETL.JSON.Core v1.2.1.45
[
[ ]
]
Expected output:
[
"12346789"
]
I’m using ChoETL.JSON.Core v1.2.1.45 beta1 https://dotnetfiddle.net/WJHC2P @Cinchoo
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Flattening a JSONObject in Java - Recursion causing ...
I'm using Iterator to loop the keys, and using hasNext() and next() to ensure that I should only be able to access specific...
Read more >Flattening JSON objects in Python
There are many ways to flatten JSON. There is one recursive way and another by using the json-flatten library. Approach 1: Recursive Approach....
Read more >Question about flatten and unflatten #1989 - nlohmann/json
IMHO, we can change the array to object when we get [json.exception.parse_error.109] parse error: array index 't' is not a number .
Read more >How to Flatten or Unflatten Complex JSON objects into Flat ...
Couple of days back I got a questions on how to flatten JSON Object which may be simple of Complex in structure? JsonFlattener...
Read more >Flattening JSON objects in Python
Flattening JSON objects involves converting complex hierarchical JSON structures to simpler structures. This process is often required when ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Because it was a key separator, if you change
.
to_
as.Configure(c => c.NestedKeySeparator = '_')
, you don’t need to wrapper by brackets, so it is just simplyvar a = r.WithField("Phone","$.Contact_Phone_Description.vi", isArray: false);
jsonpath contains special character, hence must be given in
$.['valid.key.with.dot']
format.Valid field spec
var a = r.WithField("Phone","$.[\'Contact.Phone.Value\']", isArray: false);
Sample fiddle: https://dotnetfiddle.net/B1BkFi