A cycle-safe, PocketBase-compatible JSON stringifier.
npm install pocketbase-stringifyA cycle-safe, PocketBase-compatible JSON stringifier.
``bash`
npm install pocketbase-stringify
`typescript
import { stringify, parse, toObject } from 'pocketbase-stringify'
// Safely stringify objects with circular references
const circular = { a: 1 }
circular.self = circular
stringify(circular) // Handles circular references
// Special types are handled automatically
stringify({
error: new Error('oops'),
regex: /test/,
fn: () => console.log('hello'),
})
// Parse JSON strings
const obj = parse(jsonString)
// Parse JSON strings with type support
const obj = parse
// Convert complex objects to plain objects
const plainObj = toObject(complexObj)
// Convert complex objects to plain objects of a specific type
const plainObj = toObject
`
- stringify(obj, replacer?, space?) - Stringify with circular reference detectionparse
- - Safe JSON.parse with type supporttoObject
-