Json.FromValue

This function generates a JSON format of a given value, using a specified text encoding provided by encoding. If encoding is not specified, UTF8 is used as the default. The values are represented in t...

Syntax

Json.FromValue(value as any, optional encoding as nullable number) as binary

About

This function generates a JSON format of a given value, using a specified text encoding provided by encoding. If encoding is not specified, UTF8 is used as the default. The values are represented in the following way: - Null, text, and logical values are represented using their corresponding JSON types. - Numbers are represented as numbers in JSON format, with the exception of #infinity, -#infinity, and #null which are converted to null. - Lists are shown as JSON arrays. - Records are displayed as JSON objects. - Tables are depicted as an array of objects. - Dates, times, datetimes, datetimezones, and durations are represented in ISO-8601 text format. - Binary values are shown as base-64 encoded text. - Errors may occur when dealing with types and functions.

Explanation

Transform a complex data type into JSON format using Power Query. Utilize the MText.FromBinary function along with Json.FromValue to achieve this. The resulting JSON output will show the converted values as a string. For example, the value of A will appear as an array containing integers, boolean, and strings, while the value of B will be formatted as a date in the output. The final JSON output will accurately represent the original complex data structure in an easily understandable format.