Skip to content

iamcal/flamework-JSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Flamework-JSON - Decode bad 'JSON' in PHP

The built-in PHP JSON decoder is very strict, and will not accept things which are fairly common in the wild:

  • unquoted keys, e.g. {foo: 1}
  • single-quoted strings, e.g. {"foo": 'bar'}
  • escaped single quoted, e.g. {"foo": "b'ar"}
  • empty array elements, e.g. [1,,2]

This library allows you to decode JavaScript objects as if they were valid JSON.

Usage

include('lib_json.php');

$obj = json_decode_loose($str);

If you're using Flamework, just drop lib_json.php into your include folder.

Testing

If you have perl's Test::Harness installed (you almost certainly do), you can run the tests using:

prove --exec 'php' t/*.t

About

Decode bad 'JSON' in PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published