2017 © Pedro Peláez
 

library cleanjson

A simple wrapper around PHP's Json functions giving a simple approach to error checking on decode.

image

davidfricker/cleanjson

A simple wrapper around PHP's Json functions giving a simple approach to error checking on decode.

  • Sunday, February 12, 2017
  • by sousdev
  • Repository
  • 1 Watchers
  • 2 Stars
  • 27 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

CleanJson

A simple wrapper around PHP's JSON functions giving a simple approach to error checking on decode., (*1)

Example

All methods are static so an example useage would be as follows:, (*2)

<?php
  if(Json::decode("{}", false) === false)
  {
    // string does not contain valid JSON data.
    echo Json::get_error_message();
  }
?>

Why

This class is a simple wrapper around PHP's JSON functions. It aims to make error detection and parsing simpler than it currently is. For example the decode method decodes a JSON string and returns the resulting object/array. If the decode operation fails the wrapper function will return FALSE, unlike the default implementation which returns NULL. The issue here being that a valid JSON string can be decoded and result in NULL also. This is not always desireable., (*3)

License

Released under the MIT license., (*4)

The Versions

12/02 2017

dev-master

9999999-dev

A simple wrapper around PHP's Json functions giving a simple approach to error checking on decode.

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

12/02 2017

1.1

1.1.0.0

A simple wrapper around PHP's Json functions giving a simple approach to error checking on decode.

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

05/02 2017

v1.0

1.0.0.0

A simple wrapper around PHP's Json functions giving a simple approach to error checking on decode.

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0