2.0.1 • Published 8 years ago

is-json v2.0.1

Weekly downloads
18,293
License
ISC
Repository
github
Last release
8 years ago

is-json

Build Status

check if a string is a valid JSON string without using Try/Catch and is a JSON object

V1.2

isJSON(str*, passObjects=bool)

*with passObjects = true can pass a JSON object in str, default to false

  var isJSON = require('is-json');

  var good_json = '{"a":"obja","b":[0,1,2],"c":{"d":"some object"}}';
  var bad_json = '{"a":"obja""b":[0,1,2],"c":{"d":"some object"}}';
  var str_number = '121212';


  console.log(isJSON(good_json)); // true
  console.log(isJSON(bad_json)); // false
  console.log(isJSON(str_number)); // false



  // check is an object

  var object = {a: 12, b: [1,2,3]};

  console.log(isJSON(object, true)); // true

// can use isJSON.strict (uses try/catch) if wants something more robust

console.log(isJSON.strict('{\n "config": 123,\n "test": "abcde" \n}')); // true
voip-web-sdk-testct-platform-backendauthpushauthlogin@schinfotech/sch-rule-enginenpm-cult-test@mintyjs/content-awaredeyu_utilteasim-scriptsvisitjs@infinitebrahmanuniverse/nolb-is-jeleet-client@everything-registry/sub-chunk-1934swagger-editorswagger-editor-binaryswagger-editor-npm-packageswagger-editor-offlinevue-gitpagerethinkdb-stream-chunkerrequest-mockeryrezoomrelabredierootesequelize-utilsrevelation-servertestmybotmimi-alipay-sdklf-ui-kitload-envhermes-utilshermes-adaptorhermes-bridgejson-config-lambda-handlerisodevinter-bridgeirjs-thingiverseipc-jsonirie-utilslivecoin-tcpmorpheus.jskafka-rxjskenote-node-utilsgsof-electron-oauth2hithercontenthammock-botjason-project-apijason-utilsjb-v-plugin-globalmy-vue-templatemc-storagemeasurement-frameworkmeasurement-frameworkspackage-example.jsonoptic-skills-sdkposthtml-componentsposthtml-modulesposthtml-renderpostman-runnernode-cache-redisnode-cache-redis-forknode-red-contrib-data-mappernode-redis-connection-poolnode-redis-storenetasobear-mockstudy-managersqueezer-event-nodestring-2-objectstimpaksmart-web-resourcesmart-configsimple-redis-cachesite-mobile-friendly@artgenio/core@ant-basement/ant-biz-service@aliyun-sls/dashboard@aliyun-sls/ingestion@aliyun-sls/logsearch@abidibo/js-word-eventyobit-exchange-apiyellowlabtoolsyandex-tank-ammoyp-visionpay-sdkzhifubao-payvis-express-proxy-mockvis-fe-dev-utilsurld@dustin-bbc/botium-core@edx/frontend-create-react-app@edx/create-edx-react-app@frodzislaw/front3@innotrade/enapso-ontology-uploader@lego-js/tests@metta/mt-v-plugin-global@metta/mt-vue-framework@naktibalda/testmybot@exp-plus/alipay-sdk@mobileforming/alipay-sdk@mobileforming2/alipay-sdk
2.0.1

8 years ago

2.0.0

9 years ago

1.2.5

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

11 years ago

1.1.2

11 years ago

1.1.1

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago