simple-json-tools
v1.1.0
Published
Use JSON way easier than it ever was.
Downloads
19
Readme
simple-json-tools
by PilotTim136
This package provides a set of helper functions to simplify common JSON operations, making it easier to handle arrays and objects in JSON format.
Features
Some highlights of this package:
- Easy value manipulation in JSON arrays
- Convenient methods for checking and retrieving data by key
- Functions for updating, adding, and deleting JSON data
All available functions are listed below.
Functions
addValue(jsonArray, value)
Adds a new value to the end of the array.
Returns: updated arrayaddValueTop(jsonArray, value)
Adds a new value to the beginning of the array.
Returns: updated arrayturnJson(value)
Parses a JSON string into an object or array (similar toJSON.parse).
Returns: object/arrayturnString(value)
Converts an object or array to a JSON string (similar toJSON.stringify).
Returns: stringexists(value, jsonArray, key)
Checks if a specified key-value pair exists in an array of objects.
Returns: booleanexistValue(value, jsonArray, key)
Finds and returns the value associated with a specified key in an array of objects, if it exists.
Returns: any or nullgetObjData(value, jsonArray, key)
Retrieves an entire object from an array where the specified key has the given value.
Returns: object or nulldeleteObject(searchKey, searchValue, jsonArray)
Deletes an object in the array where the specified key has the given value.
Returns: updated array
Note: Deprecated functions are not listed here.
