2.0.1 • Published 6 years ago

is-json v2.0.1

Weekly downloads
18,293
License
ISC
Repository
github
Last release
6 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@will3/rpc-client@zhxcloud/cloud-componentsada-cli@mintyjs/content-awareaidoalipay-sdkalipay-sdk-fixedalipay-sdk-testaliyun-voip-web-sdkdeyu_utilteasim-scriptsanalysis-logger@edx/create-edx-react-app@edx/frontend-create-react-app@exp-plus/alipay-sdkvisitjs@dustin-bbc/botium-coredbet-channels-backendcreate-phoenixpan-appbase64-text-decoderbotium-corebotium-cli@starsoul/fruitdag-pipelinediesel-jsdevice-mqttdvp-commonexpress-proxy-mockfactory-xfaker-jsonfamiliarchhyun-utilscj2gelfenoche2e-api-cucumbereleet-clientload-envlivecoin-tcpgabriel-iogabriel-serverform-packmc-storagemeasurement-frameworkmeasurement-frameworksget-typegenerator-bootstrap-boilerplate-templategsof-electron-oauth2hammock-botkenote-node-utilskafka-rxjsjson-config-lambda-handlerirjs-thingiverseirie-utilsipc-jsonisodevinter-bridgejason-utilsjason-project-apihithercontenthermes-adaptorhermes-bridgehermes-utilsjb-v-plugin-globalmimi-alipay-sdk@rucloud/cloud-components@rucloud/cloud-scss@rucloud/cloud-serve@syedsadiqali11/emoji-martapiizeapim-swagger-editorapim-swagger-editor-casapim-swagger-editor-gasapipushnode-cache-redisnode-cache-redis-forknetasmongodb-query-parsermy-vue-templatemorpheus.jsnode-red-contrib-data-mappernode-redis-storerezoomrequest-mockeryrethinkdb-stream-chunkerrevelation-serverrelabsite-mobile-friendlysimple-redis-cachesmart-configsmart-web-resourcesequelize-utilsoptic-skills-sdknode-redis-connection-poolobear-mock
2.0.1

6 years ago

2.0.0

7 years ago

1.2.5

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago