Modules@robinpath/json

@robinpath/json

0.1.0Public

JSON manipulation: parse, stringify, deep merge, flatten, unflatten, diff, query by path, pick, and omit

@robinpath/json

JSON manipulation: parse, stringify, deep merge, flatten, unflatten, diff, query by path, pick, and omit

Category Functions Auth License

Why use this module?

The json module lets you:

  • Parse a JSON string into an object
  • Convert a value to a JSON string
  • Get a nested value by dot-separated path
  • Deep merge two or more objects
  • Flatten a nested object to dot-notation keys

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/json

Quick Start

No credentials needed — start using it right away:

json.stringify $obj

Available Functions

FunctionDescription
json.parseParse a JSON string into an object
json.stringifyConvert a value to a JSON string
json.getGet a nested value by dot-separated path
json.setSet a nested value by dot-separated path, returning a new object
json.mergeDeep merge two or more objects
json.flattenFlatten a nested object to dot-notation keys
json.unflattenUnflatten dot-notation keys back to a nested object
json.diffCompare two objects and return differences
json.cloneDeep clone an object
json.isValidCheck if a string is valid JSON
json.keysGet all keys including nested paths with dot notation
json.pickPick specific keys from an object
json.omitOmit specific keys from an object

Examples

Convert a value to a JSON string

json.stringify $obj

Get a nested value by dot-separated path

json.get $obj "user.name"

Set a nested value by dot-separated path, returning a new object

json.set $obj "user.name" "Bob"

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/json";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  json.stringify $obj
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/json
Version0.1.0
LicenseMIT
Unpacked Size5.2 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

utilities