All Projects → colinodell → Json5

colinodell / Json5

Licence: mit
UTF-8 compatible JSON5 parser for PHP

Labels

Projects that are alternatives of or similar to Json5

Application Insights Workbooks
Templates for Azure Monitor Workbooks
Stars: ✭ 180 (-4.76%)
Mutual labels:  json
Jstoolnpp
A JavaScript (JSON) tool for Notepad++ (formerly JSMinNpp) and Visual Studio Code.
Stars: ✭ 186 (-1.59%)
Mutual labels:  json
Jq Web
jq in the browser with emscripten.
Stars: ✭ 188 (-0.53%)
Mutual labels:  json
Stubbornjava
Unconventional Java code for building web servers / services without a framework. Think dropwizard but as a seed project instead of a framework. If this project had a theme it would be break the rules but be mindful of your decisions.
Stars: ✭ 184 (-2.65%)
Mutual labels:  json
Json File Store
A simple JSON store for Node.js
Stars: ✭ 186 (-1.59%)
Mutual labels:  json
Libxo
The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application decides at run time which output style should be produced.
Stars: ✭ 185 (-2.12%)
Mutual labels:  json
Feed Module
Everyone deserves RSS, ATOM and JSON feeds!
Stars: ✭ 182 (-3.7%)
Mutual labels:  json
Srsly
🦉 Modern high-performance serialization utilities for Python (JSON, MessagePack, Pickle)
Stars: ✭ 189 (+0%)
Mutual labels:  json
Json To Simple Graphql Schema
Transforms JSON input into a GraphQL schema
Stars: ✭ 185 (-2.12%)
Mutual labels:  json
Autoserver
Create a full-featured REST/GraphQL API from a configuration file
Stars: ✭ 188 (-0.53%)
Mutual labels:  json
Kazaam
Arbitrary transformations of JSON in Golang
Stars: ✭ 184 (-2.65%)
Mutual labels:  json
Dalsoft.restclient
The C# REST Client - the only REST/ HTTP Client you will ever need
Stars: ✭ 185 (-2.12%)
Mutual labels:  json
Cryptocurrencies
📋 Get a list of all the cryptocurrency symbols and names.
Stars: ✭ 186 (-1.59%)
Mutual labels:  json
License List Data
Various data formats for the SPDX License List including RDFa, HTML, Text, and JSON
Stars: ✭ 182 (-3.7%)
Mutual labels:  json
Know Your Http Well
HTTP headers, media-types, methods, relations and status codes, all summarized and linking to their specification.
Stars: ✭ 2,205 (+1066.67%)
Mutual labels:  json
Go init
一个用go组织项目结构,主要包括 gin, goredis, gorm, websocket, rabbitmq等。👉
Stars: ✭ 183 (-3.17%)
Mutual labels:  json
Simdjson
Parsing gigabytes of JSON per second
Stars: ✭ 15,115 (+7897.35%)
Mutual labels:  json
Rapidyaml
Rapid YAML - a library to parse and emit YAML, and do it fast.
Stars: ✭ 183 (-3.17%)
Mutual labels:  json
Wretch
A tiny wrapper built around fetch with an intuitive syntax. 🍬
Stars: ✭ 2,285 (+1108.99%)
Mutual labels:  json
Vcspull
🔄 synchronize projects via yaml/json manifest. built on libvcs
Stars: ✭ 187 (-1.06%)
Mutual labels:  json

JSON5 for PHP - JSON for Humans

Latest Version on Packagist PHP 7.1+ Software License Build Status Coverage Status SensioLabs Insight UTF-8 Compatible Total Downloads

This library is a PHP fork of the JSON5 reference implementation.

JSON5 is a JS-compatible extension to JSON which allows comments, trailing commas, single-quoted strings, and more:

{
    foo: 'bar',
    while: true,

    this: 'is a \
multi-line string',

    // this is an inline comment
    here: 'is another', // inline comment

    /* this is a block comment
       that continues on another line */

    hex: 0xDEADbeef,
    half: .5,
    delta: +10,
    to: Infinity,   // and beyond!

    finally: 'a trailing comma',
    oh: [
        "we shouldn't forget",
        'arrays can have',
        'trailing commas too',
    ],
}

See the JSON5 website for additional examples and details.

Install

Via Composer

$ composer require colinodell/json5

Usage

This package adds a json5_decode() function which is a drop-in replacement for PHP's built-in json_decode():

$json = file_get_contents('foo.json5');
$data = json5_decode($json);

It takes the same exact parameters in the same order. For more details on these, see the PHP docs.

To achieve the best possible performance, it'll try parsing with PHP's native function (which usually fails fast) and then falls back to JSON5.

Exceptions

This function will always throw a SyntaxError exception if parsing fails. This is a subclass of the new \JsonException introduced in PHP 7.3. Providing or omitting the JSON_THROW_ON_ERROR option will have no effect on this behavior.

For users on PHP 7.2 and below: a PHP 7.3 polyfill is included with this library so that you can safely reference \JsonException and JSON_THROW_ON_ERROR in your own code.

Binary / Executable

A binary/executable named json5 is also provided for converting JSON5 to plain JSON via your terminal.

Usage: json5 [OPTIONS] [FILE]

  -h, --help  Shows help and usage information

  (Reading data from STDIN is not currently supported on Windows)

Examples:

Converting a file named file.json5:

json5 file.json5

Converting a file and saving its output:

json5 file.json5 > file.json

Converting from STDIN:

echo -e "{hello: 'world!'}" | json5

Converting from STDIN and saving the output:

echo -e "{hello: 'world!'}" | json5 > output.json

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Support

In addition to standard support, consider a Tidelift Subscription for professional support and get alerted when new releases or security issues come out.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].