Skip to content

abimek/php-json-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PhPJsonParser

A simple reusable php OOP API for reading and manipulating json data from files.

Why

This php library was specifically built for massive json-based configs, such as minecrafts Bedrock Edition addon system. Massive json based config systems usually have some identical json data/fields between configs. And managing them is sometimes an annoying hassle. Using this api you can write json parsers that are moulder allowing you to implement the same reader twice.

Requirements

The following PHP versions are guaranteed to work.

  • PHP 5.6
  • PHP 7
  • PHP 8

Usage

Download the library using composer:

$ composer require abimekuriya/php-json-parser

We can now begin working with the Api.

Quick Example

<?php
use abimek\JsonParser\FileJsonParser;
use abimek\JsonParser\parsers\ComponentParser;
use abimek\JsonParser\requirements\Requirement;

 ComponentParser::register(new ComponentParser("nameIdentifier", function ($data, &...$args){
     $args[0] = $data["name"];
     $args[1] = $data["identifier"];
 }));
$fileParser = FileJsonParser::create(getcwd() . "/test.json", []);
$fileParser->addParseComponent(ComponentParser::get("nameIdentifier", $name, $identifier), [new Requirement("name", Requirement::TYPE_STRING)]);
$fileParser->onComplete(function ()use(&$name, &$identifier){
    echo $name;
    echo $identifier;
});
$fileParser->execute();

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages