npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@interaktiv/json

v1.0.0

Published

JSON related utilities for Javascript at DIA

Downloads

19

Readme

@interaktiv/json

JSON related utilities for Javascript at DIA

Commitizen friendly Conventional Commits Semantic Release Code of Conduct MIT License

npm latest version npm next version

This Solution

This library includes a high level support for parsing and working with JSON data.

Table of Contents

Installation

This module can be installed via npm which is bundled with Node.js and should be installed as one of your project's dependencies:

npm install --save @interaktiv/json

API

cloneJson

Perform a deep clone of an object or array compatible with JSON stringification. Object fields that are not compatible with stringification will be omitted. Array entries that are not compatible with stringification will be censored as null.

throws JsonStringifyError If the object contains circular references or causes other JSON stringification errors.

cloneJson(obj): obj

getJsonValuesByName

Finds all elements with a given name in a JsonMap. Not suitable for use with object graphs containing circular references. The specification of an appropriate type that will satisfy all matching element values is the responsibility of the caller.

getJsonValuesByName(json: obj, name: string): obj[]

isJson

Tests wether the given string is a JSON stringified string or not.

isJson(str: string): boolean

jsonIncludes

Tests whether an any JSON value contains another any JSON value. This is a shallow check only and does not recurse deeply into collections.

jsonIncludes(json: obj, value: obj): boolean

parseJson

Parse JSON string data.

throws JsonParseError If the data contents are empty or the data is invalid.

parseJson(data: string, jsonPath?: undefined | string, throwOnEmpty?: boolean): AnyJson

parseJsonMap

Parse JSON string data, expecting the result to be an object.

throws JsonParseError If the data contents are empty or the data is invalid.

throws JsonDataFormatError If the data contents are not a JsonMap.

parseJsonMap(data: string, jsonPath?: undefined | string, throwOnEmpty?: undefined | false | true): obj

References

This library is using custom error types and type narrowing from @interaktiv/errors and @interaktiv/types.

Other Use Cases

If you lack some use cases, you are welcome to open a pull request and add it. We'll come back to you and see how we can support your use case and present it to all devs.

Please consult the contribution guides before contributing.

Acknowledgements

This library is inspired by @salesforce/kit. Thank you 💙

License

MIT Copyright © 2019-present die.interaktiven GmbH & Co. KG