All Projects → crazyxman → Simdjson_php

crazyxman / Simdjson_php

Licence: apache-2.0
simdjson_php bindings for the simdjson project. https://github.com/lemire/simdjson

Projects that are alternatives of or similar to Simdjson php

Flatjson
A fast JSON parser (and builder)
Stars: ✭ 39 (-56.67%)
Mutual labels:  json, json-parser
Jsmnsol
A JSON parser for solidity
Stars: ✭ 56 (-37.78%)
Mutual labels:  json, json-parser
Univalue
High performance RAII C++ JSON library and universal value object class
Stars: ✭ 46 (-48.89%)
Mutual labels:  json, json-parser
Jsondoc
JSON object for Delphi based on IUnknown and Variant
Stars: ✭ 20 (-77.78%)
Mutual labels:  json, json-parser
Dictfier
Python library to convert/serialize class instances(Objects) both flat and nested into a dictionary data structure. It's very useful in converting Python Objects into JSON format
Stars: ✭ 67 (-25.56%)
Mutual labels:  json, json-parser
Jsonpath Rs
JSONPath for Rust
Stars: ✭ 31 (-65.56%)
Mutual labels:  json, json-parser
Lazyjson
A very fast, very lazy JSON parser for Java.
Stars: ✭ 55 (-38.89%)
Mutual labels:  json, json-parser
Jsonui
jsonui is an interactive JSON explorer on your command line
Stars: ✭ 583 (+547.78%)
Mutual labels:  json, json-parser
Zzzjson
The fastest JSON parser written in pure C
Stars: ✭ 66 (-26.67%)
Mutual labels:  json, json-parser
Njson
Unmarshal/Decode nested JSON by JSON Path
Stars: ✭ 61 (-32.22%)
Mutual labels:  json, json-parser
Xml Js
Converter utility between XML text and Javascript object / JSON text.
Stars: ✭ 874 (+871.11%)
Mutual labels:  json, json-parser
Mir Ion
WIP, use libmir/asdf package for now
Stars: ✭ 78 (-13.33%)
Mutual labels:  json, json-parser
Spray Json
A lightweight, clean and simple JSON implementation in Scala
Stars: ✭ 917 (+918.89%)
Mutual labels:  json, json-parser
Parson
Lightweight JSON library written in C.
Stars: ✭ 965 (+972.22%)
Mutual labels:  json, json-parser
Djson
Fast Go decoder for dynamic JSON
Stars: ✭ 588 (+553.33%)
Mutual labels:  json, json-parser
Gofasion
A lightweight json parsing library for golang.
Stars: ✭ 52 (-42.22%)
Mutual labels:  json, json-parser
Json
JSON for Modern C++
Stars: ✭ 27,824 (+30815.56%)
Mutual labels:  json, json-parser
Pikkr
JSON parser which picks up values directly without performing tokenization in Rust
Stars: ✭ 580 (+544.44%)
Mutual labels:  json, json-parser
Gjson
Get JSON values quickly - JSON parser for Go
Stars: ✭ 9,453 (+10403.33%)
Mutual labels:  json, json-parser
Fastjson
Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection
Stars: ✭ 1,164 (+1193.33%)
Mutual labels:  json, json-parser

simdjson_php

simdjson_php bindings for the simdjson project.

Requirement

  • PHP 7 +
  • We support platforms like Linux or macOS
  • Prerequisites: g++ (version 7 or better) or clang++ (version 6 or better), and a 64-bit system with a command-line shell (e.g., Linux, macOS, freeBSD). We also support programming environnements like Visual Studio and Xcode, but different steps are needed

Compile simdjson_php in Linux

$ phpize
$ ./configure
$ make
$ make test
$ make install

Add the following line to your php.ini

extension=simdjson.so

simdjson_php Usage

//Check if a JSON string is valid:
$isValid = simdjson_is_valid($jsonString); //return bool

//Parsing a JSON string. similar to the json_decode() function but without the fourth argument
$parsedJSON = simdjson_decode($jsonString, true, 512); //return array|object|null. "null" string is not a standard json

/*
{
  "Image": {
    "Width":  800,
    "Height": 600,
    "Title":  "View from 15th Floor",
    "Thumbnail": {
      "Url":    "http://www.example.com/image/481989943",
      "Height": 125,
      "Width":  100
    },
    "Animated" : false,
    "IDs": [116, 943, 234, 38793, {"p": "30"}]
  }
}
*/

//note. "/" is a separator. Can be used as the "key" of the object and the "index" of the array
//E.g. "Image/Thumbnail/Url" is ok.


//get the value of a "key" in a json string
$value = simdjson_key_value($jsonString, "Image/Thumbnail/Url");
var_dump($value); // string(38) "http://www.example.com/image/481989943"

$value = simdjson_key_value($jsonString, "Image/IDs/4", true);
var_dump($value); 
/*
array(1) {
  ["p"]=>
  string(2) "30"
}
*/

//check if the key exists. return true|false|null. "true" exists, "false" does not exist, "null" string is not a standard json
$res = simdjson_key_exists($jsonString, "Image/IDs/1");
var_dump($res) //bool(true)

// count the values
$res = simdjson_key_count($jsonString, "Image/IDs");
var_dump($res) //int(5)

Benchmarks

See the benchmark folder for more benchmarks.

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].