safe-json-parse

WebJar for safe-json-parse

License

License

MIT
Categories

Categories

JSON Data
GroupId

GroupId

org.webjars.bowergithub.raynos
ArtifactId

ArtifactId

safe-json-parse
Last Version

Last Version

4.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

safe-json-parse
WebJar for safe-json-parse
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/Raynos/safe-json-parse

Download safe-json-parse

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.raynos/safe-json-parse/ -->
<dependency>
    <groupId>org.webjars.bowergithub.raynos</groupId>
    <artifactId>safe-json-parse</artifactId>
    <version>4.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.raynos/safe-json-parse/
implementation 'org.webjars.bowergithub.raynos:safe-json-parse:4.0.0'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.raynos/safe-json-parse/
implementation ("org.webjars.bowergithub.raynos:safe-json-parse:4.0.0")
'org.webjars.bowergithub.raynos:safe-json-parse:jar:4.0.0'
<dependency org="org.webjars.bowergithub.raynos" name="safe-json-parse" rev="4.0.0">
  <artifact name="safe-json-parse" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.raynos', module='safe-json-parse', version='4.0.0')
)
libraryDependencies += "org.webjars.bowergithub.raynos" % "safe-json-parse" % "4.0.0"
[org.webjars.bowergithub.raynos/safe-json-parse "4.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.bowergithub.mmalecki » rust-result.js jar [1.0.0,2)

Project Modules

There are no modules declared in this project.

safe-json-parse

build status dependency status

Parse JSON safely without throwing

Example (callback)

var safeParse = require("safe-json-parse/callback")

safeParse("{}", function (err, json) {
    /* we have json */
})

safeparse("WRONG", function (err) {
    /* we have err! */
})

Example (tuple)

var safeParse = require("safe-json-parse/tuple")

var tuple1 = safeParse("{}")
var json = tuple1[1] /* we have json */

var tuple2 = safeparse("WRONG")
var err = tuple2[0] /* we have err! */

var tuple3 = safeParse(something)
if (tuple3[0]) {
    var err = tuple3[0]
    // handle err
} else {
    var json = tuple3[1]
    // handle json
}

Example (result)

var Result = require('rust-result')
var safeParse = require('safe-json-parse/result')

var result1 = safeParse("{}")
var json = Result.Ok(result1) /* we have json */

var result2 = safeparse("WRONG")
var err = Result.Err(result2) /* we have err! */

var result3 = safeParse(something)
if (Result.isErr(result3)) {
    var err = Result.Err(result3)
    // handle err
} else if (Result.isOk(result3)) {
    var json = Result.Ok(result3)
    // handle json
}

Installation

npm install safe-json-parse

Contributors

  • Raynos

MIT Licenced

Versions

Version
4.0.0