@everymundo/json-utils

1.1.1 • 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;

Readme

Keywords

Package Sidebar

Install

npm i @everymundo/json-utils

Weekly Downloads

46

Version

1.1.1

License

MIT

Unpacked Size

4.85 kB

Total Files

6

Last publish

Collaborators

  • volodymyrpetrov
  • a11y-dev
  • jsalvadorpp
  • lindolo25
  • double2-us
  • ceciliagalarza
  • carla-villegas
  • eblez
  • mjremedios1985
  • mtmorell88
  • a11y_automation2
  • ramses83
  • raydel
  • alex-orga
  • estebanpablo89
  • yartiles
  • jonmorazav
  • everymundo-admin
  • ballester
  • danielsan
  • halain
  • avivero93
  • anahiem
  • herlin
  • karinfdez
  • erlin
  • front10devs
  • hdelcastillo
  • dcuevacem
  • ortega.dc98
  • pedroleon917
  • kaylingw
  • lazjramos
  • daniuska-em