Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-json-object

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-json-object

Fast test to determine if an object is JSON-like

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

This is a small package with a minimal footprint that tries to detect if an object is a JSON-like value in the most generic way possible, using the following rules for edge cases

  • Though not specified in the standard, root objects may be other values than plain objects
  • NaN and Infinitiy are not acceptable JSON values, as per the standard
  • Objects constructed with Object.create(null) will be accepted
  • Array-like objects with a length property will get accepted

These rules should cover most common use cases, while users requiring more fine-grained contol can take a look at the source (it isn't that much).

Usage

const isJSON = require('is-json-object')

class Foo {  }

isJSON({ a: 1, b: 2 }) // true
isJSON(new Foo) // false
isJSON('test test test') // true

License

The MIT License

Keywords

FAQs

Package last updated on 05 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc