Bỏ qua, đến nội dung

Cấu hình node - Get JSON Field ​

Node trích xuất giá trị field cụ thể từ object JSON phức tạp, sử dụng dot notation hoặc array index.

Bảng tham số cấu hình ​

Tham sốKiểuBắt buộcMặc địnhMô tả
sourcestringCó—Biến workflow chứa JSON object nguồn
pathstringCó—Đường dẫn trích xuất (dot notation): data.user.name
defaultValueanyKhôngnullGiá trị mặc định khi path không tồn tại
parseJsonbooleanKhôngfalseTự động parse string thành JSON trước khi trích xuất

Dữ liệu đầu ra (Output) ​

TênKiểuMô tả
resultanyGiá trị tại path (string, number, object, array, ...)
existsbooleantrue nếu path tồn tại, false nếu dùng defaultValue

Ví dụ path thường dùng ​

PathMô tảKết quả ví dụ
data.nameField đơn giản"Nguyen Van A"
items[0]Phần tử đầu tiênobject
items[-1]Phần tử cuối cùngobject
data.users[0].emailNested + array"user@example.com"
meta.pagination.totalNested nhiều cấp42

Khi nào dùng Get JSON Field vs JSON Query ​

Nhu cầuDùng node
Lấy đúng 1 field theo pathGet JSON Field
Lọc mảng theo điều kiệnJSON Query
Projection (lấy nhiều field)JSON Query
Aggregate trên mảngJSON Query

Lưu ý quan trọng ​

  • Path phân biệt hoa thường: user.Name khác user.name
  • Nếu source là string, bật parseJson: true để tự động parse thành JSON object
  • Array index âm: items[-1] lấy phần tử cuối, items[-2] lấy kế cuối
  • Khi path trỏ đến object hoặc array, kết quả là toàn bộ object/array đó
  • Nếu source là null hoặc undefined, trả về defaultValue ngay mà không báo lỗi
  • Phù hợp nhất khi xử lý response từ HTTP Request node hoặc Webhook trigger