views:

854

answers:

3
+1  Q: 

PHP-Json Problem

Hi there..

I have to similar Json files... I can json_decode read one of them... but I can't other one...

I've uploaded files to

http://www.huzursuz.com/json/json_test.rar

if would you like to see, "brother_a.php" is working, "brother.php" is not...

I don't think this is json_decode nested limit, because files are so similar...

Thanks anyone who will try to help...

A: 

It would be better if you simply posted a sample of your JSON data.

Jonathan Sampson
+3  A: 

Where did you get that huge JSON string?

According to the json_decode documentation, if the json is malformed in some ways, it will just return NULL, which is what I'm getting when I try brother.php

// the following strings are valid JavaScript but not valid JSON

// the name and value must be enclosed in double quotes
// single quotes are not valid 
$bad_json = "{ 'bar': 'baz' }";
json_decode($bad_json); // null

// the name must be enclosed in double quotes
$bad_json = '{ bar: "baz" }';
json_decode($bad_json); // null

// trailing commas are not allowed
$bad_json = '{ bar: "baz", }';
json_decode($bad_json); // null

EDIT

I ran both of your JSON files through JSONLint, a JSON validator, and, as expected, the brother+a file passed, while brother was malformed in a few spots.

Paolo Bergantino
Thanks for the link, exactly what I was looking for so long ...
Cassy
A: 

Hi,

my JSON data is huge... so I uploaded them... sorry if I made something wrong...

I got this json from YouTube.

Paolo thanks for validator... I was searching for this...