Power QueryExercises

Json.Document

Record function · By Tahir Nas · Examples run in our simulator · Published · Updated

Parses JSON text into M records and lists.

When to use it

Use it to parse JSON from an API response, a file or a text column into records and lists, then turn them into a table with Table.FromRecords or by expanding.

Syntax

Json.Document(jsonText as any, optional encoding as nullable number) as any

Returns

A record, list or value.

Example

Json.Document("{""name"": ""Ana"", ""tags"": [1, 2]}")[name]

Result

Ana

Example: an array of objects to a table

A JSON array of objects becomes a list of records, which Table.FromRecords turns into rows.

Table.FromRecords(Json.Document("[{""id"": 1, ""city"": ""Porto""}, {""id"": 2, ""city"": ""Lyon""}]"))

Result

idcity
1Porto
2Lyon

Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.

Good to know

Common mistakes

Exercises that use Json.Document

Learn more

Related functions

Official documentation: Json.Document on Microsoft Learn.