Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

How to parse single line JSON and XML via Power Query?

Hello

 

I have the following flattened (in a single line) JSON:

{"credentials":{"personalAccessTokenName":"MY_TOKEN_NAME","personalAccessTokenSecret":"qlE1g9MMh9vbrjjg==:rZTHhPpP2tUW1kfn4tjg8","site":{"contentUrl":"MarketingTeam"}}}

 

I also have the following flattened (in a single line) XML:

<tsRequest><credentials personalAccessTokenName="MY_TOKEN_NAME" personalAccessTokenSecret="qlE1g9MMh9vbrjjg==:rZTHhPpP2tUW1kfn4tjg8"><site contentUrl="MarketingTeam"/></credentials></tsRequest>

 

Can you provide a sample Power Query how to convert these into JSON and XML documents that can be further queried via Power Query?

 

I tried the below but it does not seem to be able to parse it correctly:

 

Json.FromValue("{""credentials"":{""personalAccessTokenName"":""MY_TOKEN_NAME"",""personalAccessTokenSecret"":""qlE1g9MMh9vbrjjg==:rZTHhPpP2tUW1kfn4tjg8"",""site"":{""contentUrl"":""MarketingTeam""}}}")

 

Also, there seems there is no similar command for XML.

 

Thanks!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

let
    Source = Json.Document("{""credentials"":{""personalAccessTokenName"":""MY_TOKEN_NAME"",""personalAccessTokenSecret"":""qlE1g9MMh9vbrjjg==:rZTHhPpP2tUW1kfn4tjg8"",""site"":{""contentUrl"":""MarketingTeam""}}}"),
    #"Converted to Table1" = Record.ToTable(Source),
    #"Expanded Value" = Table.ExpandRecordColumn(#"Converted to Table1", "Value", {"personalAccessTokenName", "personalAccessTokenSecret", "site"}, {"personalAccessTokenName", "personalAccessTokenSecret", "site"}),
    #"Expanded site" = Table.ExpandRecordColumn(#"Expanded Value", "site", {"contentUrl"}, {"contentUrl"})
in
    #"Expanded site"
let
    Source = Xml.Document("<tsRequest><credentials personalAccessTokenName=""MY_TOKEN_NAME"" personalAccessTokenSecret=""qlE1g9MMh9vbrjjg==:rZTHhPpP2tUW1kfn4tjg8""><site contentUrl=""MarketingTeam""/></credentials></tsRequest>"),
    #"Expanded Value" = Table.ExpandTableColumn(Source, "Value", {"Name", "Value"}, {"Name.1", "Value.1"}),
    #"Expanded Value.1" = Table.ExpandTableColumn(#"Expanded Value", "Value.1", {"Name", "Value"}, {"Name.2", "Value"}),
    #"Expanded Value1" = Table.ExpandTableColumn(#"Expanded Value.1", "Value", {"Name", "Value"}, {"Name.3", "Value.1"})
in
    #"Expanded Value1"

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

let
    Source = Json.Document("{""credentials"":{""personalAccessTokenName"":""MY_TOKEN_NAME"",""personalAccessTokenSecret"":""qlE1g9MMh9vbrjjg==:rZTHhPpP2tUW1kfn4tjg8"",""site"":{""contentUrl"":""MarketingTeam""}}}"),
    #"Converted to Table1" = Record.ToTable(Source),
    #"Expanded Value" = Table.ExpandRecordColumn(#"Converted to Table1", "Value", {"personalAccessTokenName", "personalAccessTokenSecret", "site"}, {"personalAccessTokenName", "personalAccessTokenSecret", "site"}),
    #"Expanded site" = Table.ExpandRecordColumn(#"Expanded Value", "site", {"contentUrl"}, {"contentUrl"})
in
    #"Expanded site"
let
    Source = Xml.Document("<tsRequest><credentials personalAccessTokenName=""MY_TOKEN_NAME"" personalAccessTokenSecret=""qlE1g9MMh9vbrjjg==:rZTHhPpP2tUW1kfn4tjg8""><site contentUrl=""MarketingTeam""/></credentials></tsRequest>"),
    #"Expanded Value" = Table.ExpandTableColumn(Source, "Value", {"Name", "Value"}, {"Name.1", "Value.1"}),
    #"Expanded Value.1" = Table.ExpandTableColumn(#"Expanded Value", "Value.1", {"Name", "Value"}, {"Name.2", "Value"}),
    #"Expanded Value1" = Table.ExpandTableColumn(#"Expanded Value.1", "Value", {"Name", "Value"}, {"Name.3", "Value.1"})
in
    #"Expanded Value1"

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors