Forum Discussion
Parsing Complex Json
- 5 years ago
Anonymous - unfortunately with JSON the data may not be in an ideal nested format that represents a table when extracted. You will have to expand each list to discern what is in it. You can pull those into separate columns. For example, you might have a column that looks like this:
Those are 5 integers. From there, I can convert those to text with List.Transform, then use Text.Combine. So the full M code for a new column to do this is:
#"Added Custom" = Table.AddColumn( Source, "Combined", each try Text.Combine( List.Transform( [Column1], Text.From ), ", " ) otherwise [Column1] )That will return this:
So you may have to use a combination of if/then/else or try/otherwise (the latter is like IFERROR in Excel) with a number of Text and List functions to tease out the data as you need, but we'd have to know what each list contains, and with JSON, each list could be unique.
Use the Value.Is function.
Create your Table.SelectRows statement using the UI - select anything, doesn't matter.
Then change the code from the 1st line (something like this) to the 2nd line.
each [Column1] = 1
each Value.Is([Column1], List.Type)
It will return this:
If you want things that are not a list, change the code to:
each Value.Is([Column1], List.Type) = false
- Anonymous5 years agoNot applicable
Thanks Edhans for your help, it worked perfectly