@everymundo/json-utils

    1.1.0 • Public • Published

    @everymundo/json-utils

    JSON Utilities such as safe JSON parser and pretty JSON stringifier.

    parseJson

    Whenever we use JSON.parse we have to use it inside a try-catch block because a malformed json will raise an Error.

    parseJson will do that for you and will return the Error object in case of an Error or your parsed object in case of success.

    It's also known that a function with a try-catch block in it is almost always slower than its version without a try-catch block, thus using parseJson and checking whether or not the result is an instance of Error is usually faster than using a try catch block inside your function.

    prettyJson

    This is a very simple shortcut way to use JSON.stringify(variable, undefined, ' ');, calling prettyJson(variable) looks nicer;

    Keywords

    Install

    npm i @everymundo/json-utils

    DownloadsWeekly Downloads

    11

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    4.85 kB

    Total Files

    6

    Last publish

    Collaborators

    • mtmorell88
    • a11y_automation2
    • ramses83
    • raydel
    • alex-orga
    • vladimirpetrov
    • estebanpablo89
    • yartiles
    • jonmorazav
    • emdavidmoreno
    • everymundo-admin
    • ballester
    • danielsan
    • halain
    • avivero93
    • anahiem
    • herlin
    • karinfdez
    • ernestocarrasco
    • erlin
    • front10devs
    • hdelcastillo
    • dcuevacem
    • rodneyem
    • ortega.dc98
    • pedroleon917
    • kaylingw
    • joeaspiazuem
    • lazjramos
    • daniuska-em
    • cstansfld