@stoplight/json
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "@stoplight/json", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Useful functions when working with JSON.", | ||
@@ -15,4 +15,3 @@ "keywords": [ | ||
"files": [ | ||
"**/*", | ||
"!__tests__" | ||
"**/*" | ||
], | ||
@@ -30,3 +29,3 @@ "author": "Stoplight <support@stoplight.io>", | ||
"@stoplight/fast-safe-stringify": "2.1.2", | ||
"@stoplight/types": "2.x.x", | ||
"@stoplight/types": "3.x.x", | ||
"json-source-map": "0.4.0", | ||
@@ -33,0 +32,0 @@ "lodash": "4.x.x" |
@@ -21,19 +21,24 @@ # @stoplight/json | ||
- **[decycle](https://stoplightio.github.io/json/globals.html#decycle)**: Remove circular references with support for an optional replacer. | ||
- **[parseWithPointers](https://stoplightio.github.io/json/globals.html#parsewithpointers)**: Like `JSON.parse(val)` but also returns a source map that includes a JSON path pointer for every property in the result (with line information). | ||
- **[pathToPointer](https://stoplightio.github.io/json/globals.html#pathtopointer)**: Turns an array of path segments into a json pointer IE `['paths', '/user', 'get']` -> `#/paths/~1/user/get`. | ||
- **[pointerToPath](https://stoplightio.github.io/json/globals.html#pointertopath)**: Turns a json pointer into an array of path segments IE `#/paths/~1/user/get` -> `['paths', '/user', 'get']`. | ||
- **[safeParse](https://stoplightio.github.io/json/globals.html#safeparse)**: Like `JSON.parse(val)` but does not throw on invalid JSON. | ||
- **[safeStringify](https://stoplightio.github.io/json/globals.html#safestringify)**: Like `JSON.stringify(val)` but handles circular references. | ||
- **[startsWith](https://stoplightio.github.io/json/globals.html#startswith)**: Like native JS `x.startsWith(y)` but works with strings AND arrays. | ||
- **[trimStart](https://stoplightio.github.io/json/globals.html#trimstart)**: Like `lodash.startsWith(x, y)` but works with strings AND arrays. | ||
#### Example `parseWithPointers` | ||
_Note: Unlike most of the other functions, parseWithPointers is not exported from root. You must import by name._ | ||
```ts | ||
// basic example of parseWithPointers | ||
// note: parseWithPointers is not exported from root, ust import by name | ||
import { parseWithPointers } from "@stoplight/json/parseWithPointers"; | ||
const result = parseWithPointers('{"foo": "bar"'}); | ||
console.log(result.data) // => the {foo: "bar"} JS object | ||
console.log(result.pointers) // => the source map with a single "#/foo" pointer that has position info for the foo property | ||
const result = parseWithPointers('{"foo": "bar"}'); | ||
console.log(result.data); // => the {foo: "bar"} JS object | ||
console.log(result.pointers); // => the source map with a single "#/foo" pointer that has position info for the foo property | ||
``` | ||
- **decycle**: Remove circular references with support for an optional replacer. | ||
- **parseWithPointers**: Like `JSON.parse(val)` but also returns a source map that includes a JSON path pointer for every property in the result (with line information). | ||
- **safeParse**: Like `JSON.parse(val)` but does not throw on invalid JSON. | ||
- **safeStringify**: Like `JSON.stringify(val)` but handles circular references. | ||
- **startsWith**: Like native JS `x.startsWith(y)` but works with strings AND arrays. | ||
- **trimStart**: Like `lodash.startsWith(x, y)` but works with strings AND arrays. | ||
### Contributing | ||
@@ -49,2 +54,2 @@ | ||
8. Push: `git push`. | ||
9. Open PR targeting the `develop` branch. | ||
9. Open PR targeting the `next` branch. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30048
54
+ Added@stoplight/types@3.1.0(transitive)
- Removed@stoplight/types@2.0.0(transitive)
Updated@stoplight/types@3.x.x