Skip to content

Json

example1

file

{ "name":"John",
  "country":[
    {"id":"US","prob":0.09},
    {"id":"AU","prob":0.06}
  ]
}

mlang

let
    Source = Json.Document(File.Contents("C:\tmp\name.json")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Expanded country" = Table.ExpandListColumn(#"Converted to Table", "country"),
    #"Expanded country1" = Table.ExpandRecordColumn(#"Expanded country", "country", {"id", "prob"}, {"country.id", "country.prob"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded country1",{ {"country.id", Text.Type}, {"country.prob", Number.Type} })
in
    #"Changed Type"

table

namecountry.idcountry.prob
JohnUS0.09
JohnAU0.06