json

JSON utilities for parsing, validation, conversion, and sanitization.

Functions

Function
Description
Example

counter

Count occurrences of key-value in JSON

dphelper.json.counter(data, 'status', 'active')

toCsv

Convert JSON array to CSV string

dphelper.json.toCsv(users)

saveCsvAs

Download JSON as CSV file

dphelper.json.saveCsvAs(csvData, 'export')

is

Check if string is valid JSON

dphelper.json.is('{"key": "value"}')

parse

Parse JSON string safely

dphelper.json.parse('{"key": "value"}')

sanitize

Sanitize malformed JSON string

dphelper.json.sanitize(input)

sanitizeJsonValue

Sanitize individual JSON values

dphelper.json.sanitizeJsonValue('hello')

Description

Complete JSON manipulation toolkit:

  • Validation - Check if strings are valid JSON

  • Parsing - Safe JSON parsing with error handling

  • Conversion - JSON to CSV export

  • Sanitization - Clean JSON strings, prevent injection

Usage Examples

JSON Validation

JSON Parsing

Counting JSON Properties

JSON to CSV Conversion

Save CSV as File

JSON Sanitization

Value Sanitization

Advanced Usage

Complete Data Export

JSON Validation Middleware

API Response Handler

Details

  • Author: Dario Passariello

  • Version: 0.0.2

  • Creation Date: 20210101

  • Last Modified: 20260220

  • Environment: Works in both client and server environments


Automatically generated document

Last updated