Json.FromValue is a Power Query M function that produces a JSON representation of a given value with a specified text encoding. The function returns a JSON representation of the value in UTF8 if encoding is omitted.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Json.FromValue(
value as any,
optional encoding as nullable number,
) as binary
Argument | Attribute | Description |
---|---|---|
value | Specifies the input to be converted into its JSON format representation. | |
encoding | optional | Uses the TextEncoding.Type to specify the text’s binary encoding format. By default, if not provided, the argument uses TextEncoding.Utf8 (UTF8 binary form). Other available options are: – TextEncoding.Unicode: use the UTF16 little-endian binary form. – TextEncoding.Utf16: use the UTF16 little-endian binary form. – TextEncoding.BigEndianUnicode: use the UTF16 big endian binary form. – TextEncoding.Windows: use the Windows binary form. – TextEncoding.Ascii: use the ASCII binary form. |
Description
Produces a JSON representation of a given value value
with a text encoding specified by encoding
. If encoding
is omitted, UTF8 is used. Values are represented as follows:
- Null, text and logical values are represented as the corresponding JSON types
- Numbers are represented as numbers in JSON, except that
#infinity
,-#infinity
and#nan
are converted to null - Lists are represented as JSON arrays
- Records are represented as JSON objects
- Tables are represented as an array of objects
- Dates, times, datetimes, datetimezones and durations are represented as ISO-8601 text
- Binary values are represented as base-64 encoded text
- Types and functions produce an error
Examples
Convert a complex value to JSON.
// Output: "{""A"":[1,true,""3""],""B"":""2012-03-25""}"
Text.FromBinary( Json.FromValue( [A = {1, true, "3"}, B = #date( 2012, 3, 25 )] ) )
Related functions
Other functions related to Json.FromValue are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy