---
title: Json.FromValue – แปลง Value เป็น JSON
url: https://www.thepexcel.com/functions/power-query/text-functions/json-fromvalue/
type: function-explainer
program: Power Query
syntax: "Json.FromValue(value as any, optional encoding as nullable number) as binary"
date: 2025-12-04
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# Json.FromValue – แปลง Value เป็น JSON

> แปลงค่าเป็นข้อความ JSON

## คำอธิบาย

Json.FromValue ใช้สำหรับแปลงค่าใดๆ เป็นข้อความ JSON สามารถแปลง record, list, number, logical, null และข้อความได้

## Syntax

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

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| value | Yes | any |  | ค่าที่ต้องการแปลงเป็น JSON |
| encoding | No | nullable number | UTF8 | ประเภทการเข้ารหัสของ JSON output |

## เคสการใช้งาน

### สร้าง JSON payload สำหรับ REST API

สร้าง JSON payload สำหรับ REST API

### บันทึกข้อมูล record เป็น JSON

บันทึกข้อมูล record เป็น JSON

### ส่งข้อมูล structured ไปยัง Web service

ส่งข้อมูล structured ไปยัง Web service

## ตัวอย่าง

### 1. แปลง Record เป็น JSON

```excel
Text.FromBinary(Json.FromValue([Name="John", Age=30]))
```

**ผลลัพธ์:** `{"Name":"John","Age":30}`

แปลง record เป็น JSON object

### 2. แปลง List เป็น JSON

```excel
Text.FromBinary(Json.FromValue({1, 2, 3}))
```

**ผลลัพธ์:** `[1,2,3]`

แปลง list เป็น JSON array

### 3. ส่งไป API

```excel
Text.FromBinary(Json.FromValue([ID=123, Name="Test"]))
```

**ผลลัพธ์:** `{"ID":123,"Name":"Test"}`

สร้าง JSON payload สำหรับ API call

## ฟังก์ชันที่เกี่ยวข้อง

- [Json.Document – แปลง JSON Text เป็น Power Query Record](https://www.thepexcel.com/functions/power-query/accessing-data-functions/json-document/)
- [Text.FromBinary – แปลง Binary เป็น Text](https://www.thepexcel.com/functions/power-query/text-functions/text-frombinary/)
- [Text.From – แปลงค่าเป็นข้อความ](https://www.thepexcel.com/functions/power-query/text-functions/text-from/)

## แหล่งข้อมูลเพิ่มเติม

- [Microsoft Learn: Json.FromValue](https://learn.microsoft.com/en-us/powerquery-m/json-fromvalue) _(Official Documentation)_

---

_Source: [https://www.thepexcel.com/functions/power-query/text-functions/json-fromvalue/](https://www.thepexcel.com/functions/power-query/text-functions/json-fromvalue/)_
