2017 © Pedro Peláez
 

library json-er

Simple helper class for converting data to json.

image

mead-steve/json-er

Simple helper class for converting data to json.

  • Thursday, January 31, 2013
  • by MeadSteve
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

JSONer

Small utility class to help out with converting PHP objects to json., (*1)

Example Usage

Basic usage is very straight forward:, (*2)

$jsonBuilder = new \MeadSteve\JSONer\JSONer();

$dataToOutput = array(
  'id'               => "y76",
  'requestedData'    => $ComplexObject
);

$outputString = $jsonBuilder->convertToJSON($dataToOutput);

This assumes that you want to use php's default behaviour to encode the ComplexObject. If you wanted a bit more control then ideally you would implement the JsonSerializable in the class. However If this isn't an option you can provide handler functions to the JSONer object:, (*3)

$jsonBuilder->registerSerializeFunction('ComplexObject', function($Object) {
  $moreSimpleObject = new stdClass();
  $moreSimpleObject->propertyOne = $Object->getPropertyOne();
  return $moreSimpleObject;
});

The Versions

31/01 2013

dev-master

9999999-dev

Simple helper class for converting data to json.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

24/01 2013

1.0.0

1.0.0.0

Simple helper class for converting data to json.

  Sources   Download

MIT

The Requires

  • php >=5.3.0