แชร์ผ่าน


Json.Document

วากยสัมพันธ์

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

ประมาณ

แสดงเนื้อหาของเอกสาร JSON

  • jsonText: เนื้อหาของเอกสาร JSON ค่าของพารามิเตอร์นี้สามารถเป็นข้อความหรือค่าไบนารีที่ส่งกลับโดยฟังก์ชัน เช่น File.Content
  • encoding TextEncoding.Type: ที่ระบุการเข้ารหัสที่ใช้ในเอกสาร JSON ถ้า 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

แสดงเนื้อหาของไฟล์ JSON ที่เข้ารหัส UTF16 ออนไลน์

การใช้งาน

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

เอาท์พุท

ค่าระเบียน รายการ หรือค่าดั้งเดิมที่แทนข้อมูล JSON UTF16 ที่มีอยู่ในไฟล์