Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey everyone!

sorry to ask such a simple question, but I am new to programming.

I am trying to parse a json string into a php array and I can't figure out what im doing wrong.

*** I should add that i don't see any error messages, but my array does not print when i try to print it with print_r();

Here is my code:



PHP
<?php

$jsonData = '{"id":100,"name":"Manhattan","level":1,"city":"New York","state":"NY","path":"manhattan","parent_id":1,"boundary_encoded_points_string":"kfqwFzkwbM}uAwM_iAmIgi@yQyfDm{BqmGc`Eon@ki@ir@{Ogt@cCcSia@{t@e`@}k@}Lwi@k[qBe[~Fc]lI}KzEcO^aUxFgN~I{Gd]pEff@xe@ra@h[pz@tj@hjA~b@loAoFfhAdAdf@ea@jk@{@vc@hh@dk@~[pb@lEfX_HtQ|CjWzWv|@vp@nh@vj@bYde@bf@dOri@Hvn@wBvtAtf@rS|y@zEzfA|Ofa@te@~|@{B|o@_Wd\\}n@s@","small_image_uri":"/images/no_photo_small.png","title":"Manhattan","subtitle":"in NYC","details":""}';

$phpArray = json_decode($jsonData);

print_r($phpArray);

?>
Posted
Updated 12-Dec-14 15:49pm
v2

1 solution

The culprit is this:
"boundary_encoded_points_string":"kfqwFzkwbM}uAwM_iAmIgi@yQyfDm{BqmGc`Eon@ki@ir@{Ogt@cCcSia@{t@e`@}k@}Lwi@k[qBe[~Fc]lI}KzEcO^aUxFgN~I{Gd]pEff@xe@ra@h[pz@tj@hjA~b@loAoFfhAdAdf@ea@jk@{@vc@hh@dk@~[pb@lEfX_HtQ|CjWzWv|@vp@nh@vj@bYde@bf@dOri@Hvn@wBvtAtf@rS|y@zEzfA|Ofa@te@~|@{B|o@_Wd\\}n@s@"

remove the double backslashes \\ nearing the end.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900