Reputation: 7880
my solution was :
function format_json($str)
{
...
$str = preg_replace('/([a-z]+):/i', '"$1":', $str);
$wtr = array('""',',",');
$rpw = array('"',',');
return str_replace($wtr, $rpw, $str);
}
Upvotes: 0
Views: 3714
Reputation: 10268
Like stated in previous answers, you need to add double-quote to strings. A really fast and quick way to check json string is to use JSONLint.
Here's the output you will get from JSONLint:
Parse error on line 1:
{ m: [ {
-----^
Expecting 'STRING', '}'
So you need to change all parts that don't have double quotes. For example:
{m: [ ...
Will become:
{"m": [ ...
Edit after comment: It seems that the double quotes inside strings are not escaped properly. For example:
{"m" : [ { "g": [ "32", "Brezilya-"Serie" A", "83", ...
Here -----------------------------^ and ^
Should be:
{"m" : [ { "g": [ "32", "Brezilya-\"Serie\" A", "83", ...
Upvotes: 2
Reputation: 1106
You can parse this string with class from here http://pear.php.net/pepr/pepr-proposal-show.php?id=198
require_once 'JSON.php';
$json = new Services_JSON();
$data = $json->decode($yourstring);
Upvotes: 2
Reputation: 272066
Try to run your JSON through JSONLint. To begin with, property names must be enclosed in double quotes. Then, strings must also be enclosed in double quotes instead of single quotes:
{
"m": [
{
"g": [
32,
"Brezilya-SerieA",
.
.
.
Upvotes: 2
Reputation: 6916
IN your JSON you should use " " instead of ' ' and that will get solved.
its a convention in JSON that the double qoutes will be used to define object names or objects .. try using the way u write a string in C++ for defining your json .
Upvotes: 1
Reputation: 4042
JSON only supports double-quoted strings, and all of the property names must be quoted.
Upvotes: 2