getObjectFromJSON()
is a more helpful alternative to JSON.parse()
.
The reason? Better error messages. If you pass anything other than a
string, you get 'Input must be string', and if the string is not strictly
formatted as JSON, you get 'Argument is not in JSON format'.
npm i get-object-from-json
import { getObjectFromJSON } from 'get-object-from-json';