-1

i have json string but when i am getting it json_decode() it is showing blank.


$str = '[{"actcode":"Auck4","actname":"Sky Tower","date":"","time":"","timeduration":"","adult":"0","adultprice":"28","child":"0","childprice":"0","description":"Discover the best of Auckland in half a day. Soak up spectacular sights on this scenic tour, from heritage-listed buildings on Queen Street to the stunning Viaduct Harbour and panoramic vistas from the Sky Tower observation deck.

Start your tour with a hotel pick-up and travel through Auckland?s dynamic Central Business District. Travel across the iconic Auckland Harbour Bridge and admire stunning city views. Then, return to the city centre and visit the vibrant precinct of Wynyard Quarter. Here, wander among the sculptures and enjoy the happenings on the water of Viaduct Harbour.

Continue to Queen Street, also known as the ?Golden Mile? of Aucklands business and shopping district. Marvel at historic buildings like the Ferry Terminal building before visiting the Auckland Museum. Here, explore fascinating exhibits paying tribute to New Zealands natural, Maori and European histories. Afterwards, travel along Aucklands most expensive residential streets with fantastic views of the Waitemata Harbour and its islands.

Your tour ends at Sky Tower, the tallest free-standing structure in the Southern Hemisphere. Take in breathtaking 360-degree views of the city and its surroundings. In the afternoon, continue your own exploration of Auckland."}]';

i tried the below code

$array = json_decode($str,true);
echo print_r($array);

this one too

$str1 = trim($str);
$array = json_decode($str1,true);
echo print_r($array);

but the string si showing blank


  • 1
    Your JSON isn't valid. Use `json_last_error_msg()` to help debug errors – Machavity Apr 16 '16 at 13:22
  • 4
    Possible duplicate of [Detect bad json data in PHP json\_decode()?](http://stackoverflow.com/questions/2348152/detect-bad-json-data-in-php-json-decode) – Machavity Apr 16 '16 at 13:23
  • when i delete extra spaces and newline spaces then it is getting decode –  Apr 16 '16 at 13:31

1 Answers1

-2

try this one.

$string = mysql_real_escape_string($str);
$findsym = array('\r', '\n');
$removesym = array("", "");
$strdone = stripslashes(str_replace($findsym,$removesym,strip_tags($string)));
$jsonarray = json_decode($strdone,true);
echo "<pre>"; echo print_r($jsonarray);
Ajay Kumar
  • 1,294
  • 12
  • 22