Shape JSON Data from web API

chris_k

New Member
Joined
May 4, 2017
Messages
1
I am struggling to extract the data from my JSON source (see below)

Code:
[COLOR=#000000][FONT=Consolas][{"id":"TEST1","created_at":"2017-02-22 11:55:15 +0000","updated_at":"2017-02-22 12:09:56 +0000","created_by":"chris.k@b.com","fields":[{"id[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]":"f--description","name":"Description","display_t[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]ype":"textarea","value":"Paint"},{"id":"f--date","[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]name":"Date","display_type":"date","value":"2017-0[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]3-31"},{"id":"f--location_id","name":"Location","d[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]isplay_type":"location","value":"da206e01"}],"comm[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]ents":[],"attachments":[]},{"id":"TEST2","created_[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]at":"2017-02-22 11:55:55 +0000","updated_at":"2017-02-22 12:09:56 +0000","created_by":"chris.k@b.com","fields":[{"id[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]":"f--description","name":"Description","display_t[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]ype":"textarea","value":"Dogs"},{"id":"f--date","n[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]ame":"Date","display_type":"date","value":"2017-03[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]-31"},{"id":"f--location_id","name":"Location","di[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]splay_type":"location","value":"da206e01"}],"comme[/FONT][/COLOR]<wbr style="color: rgb(0, 0, 0); font-family: Consolas, "Courier New", monospace; font-size: 12px; box-sizing: inherit;">[COLOR=#000000][FONT=Consolas]nts":[],"attachments":[]}][/FONT][/COLOR]

My goal is to have the headings:
Code:
[COLOR=#000000][FONT=Consolas]id | created_at | created_by | f--description | f--date | f--location_id[/FONT][/COLOR]

I have managed to extract the last three headings by luck more than anything using the following:

Code:
let Source = Json.Document(File.Contents("C:\Users\Chris.Kemp\Desktop\test.json")),
 #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
 #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "created_at", "updated_at", "created_by", "fields"}, {"Column1.id", "Column1.created_at", "Column1.updated_at", "Column1.created_by", "Column1.fields"}),
 #"Column1 fields" = #"Expanded Column1"{0}[Column1.fields],
 #"Converted to Table1" = Table.FromList(#"Column1 fields", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
 #"Expanded Column2" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"id"}, {"Column1.id"}),
 #"Transposed Table" = Table.Transpose(#"Expanded Column2")
in
 #"Transposed Table"

If anyone has any relevant tutorials or help it would be much appreciated.

I have tried a number of searches but I just cant get it to work.

Thanks you,
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top