Json.Document

语法

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

简介

返回 JSON 文档的内容。

  • jsonText:JSON 文档的内容。 此参数的值可以是文本或 File.Content 等函数返回的二进制值。
  • encoding:指定 JSON 文档中使用编码的TextEncoding.Type对象。 如果 encoding 省略,则使用 UTF8。

示例 1

以记录形式返回指定 JSON 文本的内容。

用法

let
    Source = "{
        ""project"": ""Contosoware"",
        ""description"": ""A comprehensive initiative aimed at enhancing digital presence."",
        ""components"": [
            ""Website Development"",
            ""CRM Implementation"",
            ""Mobile Application""
        ]
    }",
    jsonDocument = Json.Document(Source)
in
    jsonDocument

输出

[
    project = "Contosoware",
    description = "A comprehensive initiative aimed at enhancing digital presence."
    components =
    {
        "Website Development",
        "CRM Implementation",
        "Mobile Application"
    }
]

示例 2

返回本地 JSON 文件的内容。

用法

let
    Source = (Json.Document(
        File.Contents("C:\test-examples\JSON\Contosoware.json")
    )
in
    Source

输出

表示文件中包含的 JSON 数据的记录、列表或基元值

示例 3

返回联机 UTF16 编码 JSON 文件的内容。

用法

let
    Source = Json.Document(
        Web.Contents("htts://contoso.com/products/Contosoware.json"),
        TextEncoding.Utf16)
    )

输出

表示文件中包含的 JSON UTF16 数据的记录、列表或基元值