neogreco/json-request-parser

Simple class to read a json from a request no matter what type of compression/encoding has

v1.0.12 2021-11-09 14:14 UTC

This package is auto-updated.

Last update: 2024-04-09 20:02:47 UTC


README

From a Request content string and the header content encoding string, decompress and decode the info returning a Json String or null if cannot find a proper method.

Installation

This project using composer.

$ composer require neogreco/json-request-parser

Usage

Parse a json data

<?php

use JSON\tools\JSONRequestParser;

class SomeController extends Controller
{

public function index(Request $request)
    {
        try {
            $json = JSONRequestParser::extractJsonFrom($request->getContent(), $request->header('Content-Encoding'));