☰
VSuite

@vsuite/json

JSON value types and a plain-object deep merge used when vsuite merges generated settings into existing JSON config files. Non-goals: parsing (JSONC parsing lives in @vsuite/core), array merging, and schema validation.

This is a private, source-only workspace package (exports → ./src/index.ts). It is bundled into the @krizic/vsuite CLI and is not published to npm. Workspace consumers depend on it with "@vsuite/json": "workspace:*".

Public API

Export Kind Signature Description
JsonValue type string | number | boolean | null | JsonObject | JsonValue[] Any JSON value.
JsonObject type { [key: string]: JsonValue } A JSON object.
isJsonObject function (value: unknown) => value is JsonObject True for non-null, non-array objects whose prototype is Object.prototype or null.
deepMerge function (base: JsonObject, patch: JsonObject) => JsonObject Returns a new object; recursively merges keys where both sides are plain objects, otherwise the patch value overwrites (arrays are replaced, not concatenated).

Dependencies

  • Workspace: none.
  • Third-party: none.
  • Used by: @vsuite/targets, @vsuite/core.

Usage

import { deepMerge, isJsonObject, type JsonObject } from "@vsuite/json";
 
const base: JsonObject = { agent: { a: { model: "x" } }, list: [1] };
const merged = deepMerge(base, { agent: { b: { model: "y" } }, list: [2] });
// { agent: { a: {...}, b: {...} }, list: [2] }
isJsonObject(merged); // true

Testing

pnpm vitest run --project @vsuite/json