---
type: snippet
tags: ['typescript', 'json']
status: release
ctime: 2025-01-19
mtime: 2025-01-19
---

import QuoteLink from '@components/QuoteLink.astro'

<QuoteLink url="https://github.com/sindresorhus/type-fest/blob/49605b9770a344bac28ce8504045541dc0bdbd4b/source/basic.d.ts#L38-L68">
  basic.d.ts
</QuoteLink>

```ts
type JsonPrimitive = string | number | boolean | null
type JsonObject = { [Key in string]: JsonValue } & {
  [Key in string]?: JsonValue | undefined
}
type JsonArray = JsonValue[] | readonly JsonValue[]
type JsonValue = JsonPrimitive | JsonObject | JsonArray
```

예전에 JSON 타입 정의가 필요해서 찾아봤던 내용

- `JsonObject`: 문자열 키와 JsonValue 타입의 값을 가진 JSON 객체를 정의
- `JsonArray`: JsonValue 타입의 요소를 포함하는 JSON 배열을 정의
- `JsonPrimitive`: 문자열, 숫자, 불린, 또는 null과 같은 유효한 JSON 기본 값을 정의
- `JsonValue`: 유효한 JSON 값을 나타내며, JsonPrimitive, JsonObject, 또는 JsonArray로 구성

---

- https://github.com/sindresorhus/type-fest/blob/main/source/jsonify.d.ts
