jsonencode 함수

jsonencode 함수

jsonencode 는 주어진 값을 JSON 문법을 사용해서 문자열로 인코딩해요.

출처: 문서

본문

jsonencode 는 주어진 값을 JSON 문법을 사용해서 문자열로 인코딩해요. JSON 인코딩은 RFC 7159 에 정의돼요.

이 함수는 Nomad 언어 값 들을 JSON 값으로 다음과 같은 방식으로 매핑해요:

Nomad type JSON type
string String
number Number
bool Bool
list(...) Array
set(...) Array
tuple(...) Array
map(...) Object
object(...) Object
Null value null

JSON 형식은 Nomad 언어 타입을 완전히 모두 표현할 수 없으므로, jsonencode 결과를 jsondecode 에 통과시켜도 동일한 값이 나오지는 않지만, 자동 타입 변환 규칙 덕분에 실제로는 거의 문제가 되지 않아요.

Examples

> jsonencode({"hello"="world"})
{"hello":"world"}

더 알아보기 (Learn more)

  • jsondecode 는 반대 연산을 수행해요. JSON 문자열을 디코딩 해서 그 값의 표현을 얻어요.