Del via


Json.Document

Syntaks

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

Omtrent

Returnerer indholdet af JSON-dokumentet.

  • jsonText: Indholdet af JSON-dokumentet. Værdien af denne parameter kan være tekst eller en binær værdi, der returneres af en funktion, f.eks. File.Content.
  • encoding: A TextEncoding.Type , der angiver den kodning, der bruges i JSON-dokumentet. Hvis encoding udelades, bruges UTF8.

Eksempel 1

Returnerer indholdet af den angivne JSON-tekst som en post.

brug

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

Resultat

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

Eksempel 2

Returnerer indholdet af en lokal JSON-fil.

brug

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

Resultat

En post, en liste eller en primitiv værdi, der repræsenterer JSON-dataene i filen

Eksempel 3

Returnerer indholdet af en online UTF16-kodet JSON-fil.

brug

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

Resultat

En post, liste eller primitiv værdi, der repræsenterer JSON UTF16-dataene i filen