https://github.com/dedidata/services-json
Better convert to and from JSON format in PHP (json encode , json decode)
https://github.com/dedidata/services-json
json json-api json-api-serializer json-parser json-serialization php php-serializable
Last synced: 22 days ago
JSON representation
Better convert to and from JSON format in PHP (json encode , json decode)
- Host: GitHub
- URL: https://github.com/dedidata/services-json
- Owner: DediData
- Created: 2017-09-05T11:33:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-05T11:57:40.000Z (over 7 years ago)
- Last Synced: 2025-03-23T19:44:46.929Z (about 1 month ago)
- Topics: json, json-api, json-api-serializer, json-parser, json-serialization, php, php-serializable
- Language: PHP
- Homepage: https://dedidata.com
- Size: 14.6 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Services-Json
======## Better Convert to and from JSON format in PHP (json encode, json decode)
JSON (JavaScript Object Notation) is a lightweight data-interchange
format. It is easy for humans to read and write. It is easy for machines
to parse and generate. It is based on a subset of the JavaScript
Programming Language, Standard ECMA-262 3rd Edition - December 1999.
This feature can also be found in Python. JSON is a text format that is
completely language independent but uses conventions that are familiar
to programmers of the C-family of languages, including C, C++, C#, Java,
JavaScript, Perl, TCL, and many others. These properties make JSON an
ideal data-interchange language.This package provides a simple encoder and decoder for JSON notation. It
is intended for use with client-side Javascript applications that make
use of HTTPRequest to perform server communication functions - data can
be encoded into JSON notation for use in a client-side javascript, or
decoded from incoming Javascript requests. JSON format is native to
Javascript, and can be directly eval()'ed with no further parsing
overhead
#### All strings should be in ASCII or UTF-8 format!### Brief example of use:
```php
// create a new instance of Services_JSON
$json = new Services_JSON();// convert a complexe value to JSON notation, and send it to the browser
$value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
$output = $json->encode($value);print($output);
// prints: ["foo","bar",[1,2,"baz"],[3,[4]]]// accept incoming POST data, assumed to be in JSON notation
$input = file_get_contents('php://input', 1000000);
$value = $json->decode($input);// if you want to convert json to php arrays:
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
```