Handling malformed JSON in PHP - php

I'm trying to write a php script that handles data from a webservice that delivers "json" as a string. The problem is the string isn't really json; it's javascript. Specifically, the keys are not quoted, although the variables are. Example (the actual data is much longer and more complicated):
{desc:'User defined payload'}
As described by the php manual, json_decode() correctly fails to interpret this string.
My question is, how can I successfully interpret a string like this in php?
The only solution I can think of is to write some regular expressions that fix the syntax, but then I'd have two problems.
EDIT
Hadvig's suggestion of using the Services_JSON pear module worked, and looks like a general solution. Once I had the module installed, my code looked like this:
require_once 'PEAR.php';
require_once 'Services/JSON.php';
$Services_JSON = new Services_JSON();
$data = $Services_JSON->decode($malformed_json);
Unfortunately, this is SLOW. To interpret the whole string (~400,000 chars) took > 36 seconds! Using a regular expression to fix the quotes and then using json_decode took ~0.04 seconds. Here's what I used:
// fix single quotes
$s = str_replace("'", '"', $malformed_json);
// fix unquoted keys
$valid_json = preg_replace('/([{\[,])\s*([a-zA-Z0-9_]+?):/', '$1"$2":', $s);
$data = json_decode($valid_json);
Of course, this will break if the data contains any quotes, brackets, or commas.

Ok. try to use this. http://pear.php.net/pepr/pepr-proposal-show.php?id=198 I just check your string

Depends on how complicated your data is :
$output = "{desc:'User defined payload',asc:'whatever'}";
function json_js_php($string){
$string = str_replace("{",'{"',$string);
$string = str_replace(":'",'":"',$string);
$string = str_replace("',",'","',$string);
$string = str_replace("'}",'"}',$string);
return $string;
}
echo json_decode(json_js_php($output))->{'desc'};
returns : User defined payload

Using regexp is a no-go. JSON grammar cannot be correctly parsed using regexp. You will open yourself to a ton of future bugs.
I recommend using some kind of a YAML parser. YAML is backwards-compatible with JSON and allows unquoted literals at the same time.
Symfony YAML component worked great for me.
And remember that there will be a performance penalty in comparison to json_decode because it's implemented natively.

If the problem is just the unquoted identifiers and the data can be assumed not to contain any curly brackets, this should do it:
$goodJson = preg_replace("/{\s*([a-zA-Z0-9_]+)/", '{ "$1"', $badJson);
(not tested!)

Try this:
$jsonString = "{result:true,username:'usr000242',password:'123456',message:'Cannot send username and password to email#test.com'}";
function manualFixInvalidJSON($jsonString=''){
$jsonString = preg_replace("/([{,])([a-zA-Z][^: ]+):/", "\$1\"$2\":", $jsonString);
$jsonString = preg_replace("/:([a-zA-Z\'][^:]+)([,}])/", ":\"$1\"$2", $jsonString);
$jsonString = json_decode($jsonString,true);
function trimer($val){
return trim(trim($val,"'"),"\"");
}
$jsonString = array_map('trimer', $jsonString);
return json_encode($jsonString);
}
echo jsonString($jsonString);

Related

How to make a JSON String to JSON

"villageJson": "{\"newShopTraps\":[6,6,3,0,0,4,2,0,2],\"cooldowns\":[],\"last_league_shuffle\":1,\"decos\":[{\"data\":18000031,\"x\":2,\"y\":36},{\"data\":18000011,\"x\":4,\"y\":36},{\"data\":18000027,\"x\":6,\"y\":38},{\"data\":18000012,\"x\":6,\"y\":40},{\"data\":18000033,\"x\":6,\"y\":36}],\"edit_mode_shown\":true,\"buildings\":[{\"lvl\":7,\"data\":1000001,\"x\":20,\"y\":19},{\"lvl\":8,\"data\":1000004,\"x\":22,\"y\":33,\"res_timer\":0},{\"lvl\":5,\"data\":1000000,\"x\":9,\"y\":8},{\"lvl\":0,\"data\":1000015,\"x\":28,\"y\":5},{\"lvl\":3,\"data\":1000014,\"x\":20,\"y\":16},{\"lvl\":9,\"data\":1000008,\"x\":10,\"y\":23},{\"lvl\":0,\"data\":1000015,\"x\":34,\"y\":28},{\"lvl\":8,\"data\":1000002,\"x\":16,\"y\":33,\"res_timer\":120625},{\"lvl\":10,\"data\":1000003,\"x\":21,\"y\":12},{\"lvl\":10,\"data\":1000005,\"x\":13,\"y\":20},{\"lvl\":9,\"data\":1000006,\"x\":34,\"y\":15},{\"lvl\":9,\"data\":1000008,\"x\":10,\"y\":14},{\"lvl\":9,\"data\":1000009,\"x\":15,\"y\":9},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":32},{\"lvl\":7,\"data\":1000010,\"x\":5,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":5,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":6,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":8,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":9,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":10,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":11,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":12,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":25},{\"lvl\":5,\"data\":1000000,\"x\":29,\"y\":28},{\"lvl\":5,\"data\":1000013,\"x\":13,\"y\":23},{\"lvl\":5,\"data\":1000007,\"x\":29,\"y\":33},{\"lvl\":10,\"data\":1000005,\"x\":27,\"y\":16},{\"lvl\":10,\"data\":1000003,\"x\":27,\"y\":24},{\"lvl\":9,\"data\":1000009,\"x\":27,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":28},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":29},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":30},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":31},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":34,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":18},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":32},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":33},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":34},{\"lvl\":8,\"data\":1000002,\"x\":19,\"y\":33,\"res_timer\":120624},{\"lvl\":9,\"data\":1000006,\"x\":34,\"y\":18},{\"lvl\":9,\"data\":1000006,\"x\":34,\"y\":21},{\"lvl\":8,\"data\":1000002,\"x\":11,\"y\":5,\"res_timer\":120160},{\"lvl\":8,\"data\":1000002,\"x\":25,\"y\":33,\"res_timer\":120716},{\"lvl\":8,\"data\":1000004,\"x\":21,\"y\":5,\"res_timer\":0},{\"lvl\":8,\"data\":1000004,\"x\":15,\"y\":5,\"res_timer\":0},{\"lvl\":8,\"data\":1000004,\"x\":10,\"y\":17,\"res_timer\":120216},{\"lvl\":5,\"data\":1000000,\"x\":8,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":34,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":28,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":14,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":15,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":10},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":9},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":8},{\"lvl\":9,\"data\":1000008,\"x\":24,\"y\":9},{\"lvl\":9,\"data\":1000009,\"x\":14,\"y\":26},{\"lvl\":5,\"data\":1000012,\"x\":13,\"y\":15},{\"lvl\":8,\"data\":1000002,\"x\":24,\"y\":5,\"res_timer\":120218},{\"lvl\":8,\"data\":1000004,\"x\":30,\"y\":13,\"res_timer\":120687},{\"lvl\":5,\"data\":1000011,\"x\":16,\"y\":12},{\"lvl\":2,\"data\":1000020,\"x\":6,\"y\":17},{\"lvl\":8,\"data\":1000004,\"x\":14,\"y\":29,\"res_timer\":120626},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":7},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":6},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":18,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":5},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":4},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":4},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":36},{\"lvl\":5,\"data\":1000013,\"x\":24,\"y\":12},{\"lvl\":5,\"data\":1000011,\"x\":27,\"y\":21},{\"lvl\":0,\"data\":1000015,\"x\":11,\"y\":32},{\"lvl\":8,\"data\":1000002,\"x\":18,\"y\":5,\"res_timer\":120217},{\"lvl\":5,\"data\":1000000,\"x\":28,\"y\":7},{\"lvl\":9,\"data\":1000006,\"x\":34,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":4},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":35},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":34},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":33},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":32},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":31},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":30},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":29},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":5},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":6},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":7},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":9},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":10},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":12,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":29,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":10,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":18},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":18,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":15},{\"lvl\":9,\"data\":1000008,\"x\":30,\"y\":24},{\"lvl\":9,\"data\":1000008,\"x\":25,\"y\":29},{\"lvl\":9,\"data\":1000009,\"x\":17,\"y\":22},{\"lvl\":5,\"data\":1000013,\"x\":30,\"y\":16},{\"lvl\":2,\"data\":1000023,\"x\":10,\"y\":20,\"res_timer\":40689},{\"lvl\":5,\"data\":1000012,\"x\":30,\"y\":20},{\"lvl\":3,\"data\":1000024,\"x\":17,\"y\":16},{\"lvl\":3,\"data\":1000026,\"x\":6,\"y\":20},{\"lvl\":0,\"data\":1000022,\"x\":17,\"y\":19},{\"lvl\":2,\"data\":1000028,\"x\":24,\"y\":23},{\"lvl\":0,\"data\":1000015,\"x\":7,\"y\":11},{\"lvl\":10,\"data\":1000005,\"x\":23,\"y\":26},{\"lvl\":10,\"data\":1000003,\"x\":17,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":6,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":8,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":23},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":18,\"y\":25},{\"lvl\":9,\"data\":1000009,\"x\":23,\"y\":16},{\"lvl\":5,\"data\":1000013,\"x\":18,\"y\":29},{\"lvl\":5,\"data\":1000012,\"x\":21,\"y\":29},{\"lvl\":5,\"data\":1000011,\"x\":20,\"y\":26},{\"lvl\":2,\"data\":1000023,\"x\":20,\"y\":9,\"res_timer\":40691},{\"lvl\":3,\"data\":1000026,\"x\":6,\"y\":23},{\"lvl\":1,\"data\":1000029,\"x\":6,\"y\":14}],\"obstacles\":[],\"last_news_seen\":155,\"last_league_rank\":13,\"newShopBuildings\":[4,0,6,3,6,3,4,1,5,5,225,3,3,4,1,5,0,0,0,3,1,0,1,2,1,0,2,0,1,1],\"newShopDecos\":[1,4,0,1,1,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}",
"warVillage": "{\"newShopTraps\":[6,6,3,0,0,4,2,0,2],\"cooldowns\":[],\"last_league_shuffle\":1,\"decos\":[{\"data\":18000031,\"x\":2,\"y\":36},{\"data\":18000011,\"x\":4,\"y\":36},{\"data\":18000027,\"x\":6,\"y\":38},{\"data\":18000012,\"x\":6,\"y\":40},{\"data\":18000033,\"x\":6,\"y\":36}],\"edit_mode_shown\":true,\"buildings\":[{\"lvl\":7,\"data\":1000001,\"x\":20,\"y\":20},{\"lvl\":8,\"data\":1000004,\"x\":11,\"y\":34,\"res_timer\":0},{\"lvl\":5,\"data\":1000000,\"x\":10,\"y\":28},{\"lvl\":0,\"data\":1000015,\"x\":8,\"y\":30},{\"lvl\":3,\"data\":1000014,\"x\":25,\"y\":21},{\"lvl\":9,\"data\":1000008,\"x\":24,\"y\":29},{\"lvl\":0,\"data\":1000015,\"x\":37,\"y\":16},{\"lvl\":8,\"data\":1000002,\"x\":34,\"y\":13,\"res_timer\":120625},{\"lvl\":10,\"data\":1000003,\"x\":12,\"y\":24},{\"lvl\":10,\"data\":1000005,\"x\":16,\"y\":27},{\"lvl\":9,\"data\":1000006,\"x\":11,\"y\":5},{\"lvl\":9,\"data\":1000008,\"x\":18,\"y\":33},{\"lvl\":9,\"data\":1000009,\"x\":20,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":29},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":30},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":31},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":33},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":34},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":34},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":33},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":32},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":31},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":30},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":29},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":29},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":30},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":31},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":29},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":31},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":30},{\"lvl\":5,\"data\":1000000,\"x\":11,\"y\":10},{\"lvl\":5,\"data\":1000013,\"x\":20,\"y\":29},{\"lvl\":5,\"data\":1000007,\"x\":7,\"y\":6},{\"lvl\":10,\"data\":1000005,\"x\":17,\"y\":12},{\"lvl\":10,\"data\":1000003,\"x\":27,\"y\":25},{\"lvl\":9,\"data\":1000009,\"x\":16,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":8,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":8,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":9,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":28,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":34,\"y\":28},{\"lvl\":7,\"data\":1000010,\"x\":10,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":11,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":12,\"y\":15},{\"lvl\":8,\"data\":1000002,\"x\":5,\"y\":27,\"res_timer\":120624},{\"lvl\":9,\"data\":1000006,\"x\":5,\"y\":12},{\"lvl\":9,\"data\":1000006,\"x\":4,\"y\":17},{\"lvl\":8,\"data\":1000002,\"x\":23,\"y\":37,\"res_timer\":120160},{\"lvl\":8,\"data\":1000002,\"x\":35,\"y\":29,\"res_timer\":120716},{\"lvl\":8,\"data\":1000004,\"x\":18,\"y\":37,\"res_timer\":0},{\"lvl\":8,\"data\":1000004,\"x\":28,\"y\":36,\"res_timer\":0},{\"lvl\":8,\"data\":1000004,\"x\":24,\"y\":32,\"res_timer\":120216},{\"lvl\":5,\"data\":1000000,\"x\":29,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":14,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":34,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":15,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":16},{\"lvl\":9,\"data\":1000008,\"x\":22,\"y\":8},{\"lvl\":9,\"data\":1000009,\"x\":10,\"y\":16},{\"lvl\":5,\"data\":1000012,\"x\":24,\"y\":25},{\"lvl\":8,\"data\":1000002,\"x\":21,\"y\":33,\"res_timer\":120218},{\"lvl\":8,\"data\":1000004,\"x\":8,\"y\":22,\"res_timer\":120687},{\"lvl\":5,\"data\":1000011,\"x\":16,\"y\":30},{\"lvl\":2,\"data\":1000020,\"x\":37,\"y\":19},{\"lvl\":8,\"data\":1000004,\"x\":32,\"y\":25,\"res_timer\":120626},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":10},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":9},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":8},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":18,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":7},{\"lvl\":5,\"data\":1000013,\"x\":29,\"y\":21},{\"lvl\":5,\"data\":1000011,\"x\":17,\"y\":9},{\"lvl\":0,\"data\":1000015,\"x\":8,\"y\":11},{\"lvl\":8,\"data\":1000002,\"x\":33,\"y\":20,\"res_timer\":120217},{\"lvl\":5,\"data\":1000000,\"x\":28,\"y\":29},{\"lvl\":9,\"data\":1000006,\"x\":4,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":7},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":8},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":9},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":10},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":23},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":19},{\"lvl\":9,\"data\":1000008,\"x\":33,\"y\":17},{\"lvl\":9,\"data\":1000008,\"x\":8,\"y\":19},{\"lvl\":9,\"data\":1000009,\"x\":21,\"y\":16},{\"lvl\":5,\"data\":1000013,\"x\":12,\"y\":20},{\"lvl\":2,\"data\":1000023,\"x\":37,\"y\":24,\"res_timer\":40689},{\"lvl\":5,\"data\":1000012,\"x\":16,\"y\":24},{\"lvl\":3,\"data\":1000024,\"x\":25,\"y\":18},{\"lvl\":3,\"data\":1000026,\"x\":20,\"y\":4},{\"lvl\":0,\"data\":1000022,\"x\":25,\"y\":15},{\"lvl\":2,\"data\":1000028,\"x\":16,\"y\":17},{\"lvl\":0,\"data\":1000015,\"x\":16,\"y\":37},{\"lvl\":10,\"data\":1000005,\"x\":25,\"y\":12},{\"lvl\":10,\"data\":1000003,\"x\":13,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":12,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":10,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":8,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":8,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":12,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":12,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":11,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":23},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":19},{\"lvl\":9,\"data\":1000009,\"x\":29,\"y\":17},{\"lvl\":5,\"data\":1000013,\"x\":21,\"y\":12},{\"lvl\":5,\"data\":1000012,\"x\":18,\"y\":16},{\"lvl\":5,\"data\":1000011,\"x\":25,\"y\":9},{\"lvl\":2,\"data\":1000023,\"x\":29,\"y\":7,\"res_timer\":40691},{\"lvl\":3,\"data\":1000026,\"x\":15,\"y\":4},{\"lvl\":1,\"data\":1000029,\"x\":25,\"y\":4}],\"obstacles\":[],\"last_news_seen\":155,\"last_league_rank\":13,\"newShopBuildings\":[4,0,6,3,6,3,4,1,5,5,225,3,3,4,1,5,0,0,0,3,1,0,1,2,1,0,2,0,1,1],\"newShopDecos\":[1,4,0,1,1,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}"
}
That's the JSON file and whenever I try to retrieve the data by doing the following:
$randomVar = $data['villageJson']['buildings'];
It returns an error saying 'buildings' is ... offset.
So what I did is what you guys probably know is I googled why it was doing that by doing a JSON Beautifier search and what showed was an error message saying that it was not a json. Which made me scratch my head for a bit and when I remove the double quotes encapsulating the entire 'villageJson' content it now said "Strings should be wrapped in double quotes". So I came into a conclusion that this is a json string and I have to turn it into a JSON before I could call any array.
So now for the question. How do I turn this JSON String to a JSON? I had an alternative in mind by just using a search function in php and I would get my value that way but that's only if I can't get any answers here.
THanks in advanced!
$str = '{"villageJson": "{\"newShopTraps\":[6,6,3,0,0,4,2,0,2],\"cooldowns\":[],\"last_league_shuffle\":1,\"decos\":[{\"data\":18000031,\"x\":2,\"y\":36},{\"data\":18000011,\"x\":4,\"y\":36},{\"data\":18000027,\"x\":6,\"y\":38},{\"data\":18000012,\"x\":6,\"y\":40},{\"data\":18000033,\"x\":6,\"y\":36}],\"edit_mode_shown\":true,\"buildings\":[{\"lvl\":7,\"data\":1000001,\"x\":20,\"y\":19},{\"lvl\":8,\"data\":1000004,\"x\":22,\"y\":33,\"res_timer\":0},{\"lvl\":5,\"data\":1000000,\"x\":9,\"y\":8},{\"lvl\":0,\"data\":1000015,\"x\":28,\"y\":5},{\"lvl\":3,\"data\":1000014,\"x\":20,\"y\":16},{\"lvl\":9,\"data\":1000008,\"x\":10,\"y\":23},{\"lvl\":0,\"data\":1000015,\"x\":34,\"y\":28},{\"lvl\":8,\"data\":1000002,\"x\":16,\"y\":33,\"res_timer\":120625},{\"lvl\":10,\"data\":1000003,\"x\":21,\"y\":12},{\"lvl\":10,\"data\":1000005,\"x\":13,\"y\":20},{\"lvl\":9,\"data\":1000006,\"x\":34,\"y\":15},{\"lvl\":9,\"data\":1000008,\"x\":10,\"y\":14},{\"lvl\":9,\"data\":1000009,\"x\":15,\"y\":9},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":32},{\"lvl\":7,\"data\":1000010,\"x\":5,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":5,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":6,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":8,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":9,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":10,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":11,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":12,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":25},{\"lvl\":5,\"data\":1000000,\"x\":29,\"y\":28},{\"lvl\":5,\"data\":1000013,\"x\":13,\"y\":23},{\"lvl\":5,\"data\":1000007,\"x\":29,\"y\":33},{\"lvl\":10,\"data\":1000005,\"x\":27,\"y\":16},{\"lvl\":10,\"data\":1000003,\"x\":27,\"y\":24},{\"lvl\":9,\"data\":1000009,\"x\":27,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":28},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":29},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":30},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":31},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":34,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":18},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":32},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":33},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":34},{\"lvl\":8,\"data\":1000002,\"x\":19,\"y\":33,\"res_timer\":120624},{\"lvl\":9,\"data\":1000006,\"x\":34,\"y\":18},{\"lvl\":9,\"data\":1000006,\"x\":34,\"y\":21},{\"lvl\":8,\"data\":1000002,\"x\":11,\"y\":5,\"res_timer\":120160},{\"lvl\":8,\"data\":1000002,\"x\":25,\"y\":33,\"res_timer\":120716},{\"lvl\":8,\"data\":1000004,\"x\":21,\"y\":5,\"res_timer\":0},{\"lvl\":8,\"data\":1000004,\"x\":15,\"y\":5,\"res_timer\":0},{\"lvl\":8,\"data\":1000004,\"x\":10,\"y\":17,\"res_timer\":120216},{\"lvl\":5,\"data\":1000000,\"x\":8,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":37,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":34,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":28,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":14,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":15,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":10},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":9},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":8},{\"lvl\":9,\"data\":1000008,\"x\":24,\"y\":9},{\"lvl\":9,\"data\":1000009,\"x\":14,\"y\":26},{\"lvl\":5,\"data\":1000012,\"x\":13,\"y\":15},{\"lvl\":8,\"data\":1000002,\"x\":24,\"y\":5,\"res_timer\":120218},{\"lvl\":8,\"data\":1000004,\"x\":30,\"y\":13,\"res_timer\":120687},{\"lvl\":5,\"data\":1000011,\"x\":16,\"y\":12},{\"lvl\":2,\"data\":1000020,\"x\":6,\"y\":17},{\"lvl\":8,\"data\":1000004,\"x\":14,\"y\":29,\"res_timer\":120626},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":7},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":6},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":18,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":5},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":4},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":4},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":36},{\"lvl\":5,\"data\":1000013,\"x\":24,\"y\":12},{\"lvl\":5,\"data\":1000011,\"x\":27,\"y\":21},{\"lvl\":0,\"data\":1000015,\"x\":11,\"y\":32},{\"lvl\":8,\"data\":1000002,\"x\":18,\"y\":5,\"res_timer\":120217},{\"lvl\":5,\"data\":1000000,\"x\":28,\"y\":7},{\"lvl\":9,\"data\":1000006,\"x\":34,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":4},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":35},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":34},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":33},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":32},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":31},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":30},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":29},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":4},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":5},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":6},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":7},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":9},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":10},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":12,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":29,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":10,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":18},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":18,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":15},{\"lvl\":9,\"data\":1000008,\"x\":30,\"y\":24},{\"lvl\":9,\"data\":1000008,\"x\":25,\"y\":29},{\"lvl\":9,\"data\":1000009,\"x\":17,\"y\":22},{\"lvl\":5,\"data\":1000013,\"x\":30,\"y\":16},{\"lvl\":2,\"data\":1000023,\"x\":10,\"y\":20,\"res_timer\":40689},{\"lvl\":5,\"data\":1000012,\"x\":30,\"y\":20},{\"lvl\":3,\"data\":1000024,\"x\":17,\"y\":16},{\"lvl\":3,\"data\":1000026,\"x\":6,\"y\":20},{\"lvl\":0,\"data\":1000022,\"x\":17,\"y\":19},{\"lvl\":2,\"data\":1000028,\"x\":24,\"y\":23},{\"lvl\":0,\"data\":1000015,\"x\":7,\"y\":11},{\"lvl\":10,\"data\":1000005,\"x\":23,\"y\":26},{\"lvl\":10,\"data\":1000003,\"x\":17,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":5,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":6,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":8,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":23},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":18,\"y\":25},{\"lvl\":9,\"data\":1000009,\"x\":23,\"y\":16},{\"lvl\":5,\"data\":1000013,\"x\":18,\"y\":29},{\"lvl\":5,\"data\":1000012,\"x\":21,\"y\":29},{\"lvl\":5,\"data\":1000011,\"x\":20,\"y\":26},{\"lvl\":2,\"data\":1000023,\"x\":20,\"y\":9,\"res_timer\":40691},{\"lvl\":3,\"data\":1000026,\"x\":6,\"y\":23},{\"lvl\":1,\"data\":1000029,\"x\":6,\"y\":14}],\"obstacles\":[],\"last_news_seen\":155,\"last_league_rank\":13,\"newShopBuildings\":[4,0,6,3,6,3,4,1,5,5,225,3,3,4,1,5,0,0,0,3,1,0,1,2,1,0,2,0,1,1],\"newShopDecos\":[1,4,0,1,1,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}","warVillage": "{\"newShopTraps\":[6,6,3,0,0,4,2,0,2],\"cooldowns\":[],\"last_league_shuffle\":1,\"decos\":[{\"data\":18000031,\"x\":2,\"y\":36},{\"data\":18000011,\"x\":4,\"y\":36},{\"data\":18000027,\"x\":6,\"y\":38},{\"data\":18000012,\"x\":6,\"y\":40},{\"data\":18000033,\"x\":6,\"y\":36}],\"edit_mode_shown\":true,\"buildings\":[{\"lvl\":7,\"data\":1000001,\"x\":20,\"y\":20},{\"lvl\":8,\"data\":1000004,\"x\":11,\"y\":34,\"res_timer\":0},{\"lvl\":5,\"data\":1000000,\"x\":10,\"y\":28},{\"lvl\":0,\"data\":1000015,\"x\":8,\"y\":30},{\"lvl\":3,\"data\":1000014,\"x\":25,\"y\":21},{\"lvl\":9,\"data\":1000008,\"x\":24,\"y\":29},{\"lvl\":0,\"data\":1000015,\"x\":37,\"y\":16},{\"lvl\":8,\"data\":1000002,\"x\":34,\"y\":13,\"res_timer\":120625},{\"lvl\":10,\"data\":1000003,\"x\":12,\"y\":24},{\"lvl\":10,\"data\":1000005,\"x\":16,\"y\":27},{\"lvl\":9,\"data\":1000006,\"x\":11,\"y\":5},{\"lvl\":9,\"data\":1000008,\"x\":18,\"y\":33},{\"lvl\":9,\"data\":1000009,\"x\":20,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":29},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":30},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":31},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":33},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":34},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":36},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":36},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":35},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":34},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":33},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":32},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":31},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":30},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":29},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":29},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":30},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":31},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":32},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":29},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":31},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":30},{\"lvl\":5,\"data\":1000000,\"x\":11,\"y\":10},{\"lvl\":5,\"data\":1000013,\"x\":20,\"y\":29},{\"lvl\":5,\"data\":1000007,\"x\":7,\"y\":6},{\"lvl\":10,\"data\":1000005,\"x\":17,\"y\":12},{\"lvl\":10,\"data\":1000003,\"x\":27,\"y\":25},{\"lvl\":9,\"data\":1000009,\"x\":16,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":7,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":8,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":8,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":9,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":25,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":26,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":27,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":28,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":34,\"y\":28},{\"lvl\":7,\"data\":1000010,\"x\":10,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":11,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":12,\"y\":15},{\"lvl\":8,\"data\":1000002,\"x\":5,\"y\":27,\"res_timer\":120624},{\"lvl\":9,\"data\":1000006,\"x\":5,\"y\":12},{\"lvl\":9,\"data\":1000006,\"x\":4,\"y\":17},{\"lvl\":8,\"data\":1000002,\"x\":23,\"y\":37,\"res_timer\":120160},{\"lvl\":8,\"data\":1000002,\"x\":35,\"y\":29,\"res_timer\":120716},{\"lvl\":8,\"data\":1000004,\"x\":18,\"y\":37,\"res_timer\":0},{\"lvl\":8,\"data\":1000004,\"x\":28,\"y\":36,\"res_timer\":0},{\"lvl\":8,\"data\":1000004,\"x\":24,\"y\":32,\"res_timer\":120216},{\"lvl\":5,\"data\":1000000,\"x\":29,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":28},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":14,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":36,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":35,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":34,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":15,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":16},{\"lvl\":9,\"data\":1000008,\"x\":22,\"y\":8},{\"lvl\":9,\"data\":1000009,\"x\":10,\"y\":16},{\"lvl\":5,\"data\":1000012,\"x\":24,\"y\":25},{\"lvl\":8,\"data\":1000002,\"x\":21,\"y\":33,\"res_timer\":120218},{\"lvl\":8,\"data\":1000004,\"x\":8,\"y\":22,\"res_timer\":120687},{\"lvl\":5,\"data\":1000011,\"x\":16,\"y\":30},{\"lvl\":2,\"data\":1000020,\"x\":37,\"y\":19},{\"lvl\":8,\"data\":1000004,\"x\":32,\"y\":25,\"res_timer\":120626},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":33,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":10},{\"lvl\":6,\"data\":1000010,\"x\":32,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":31,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":30,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":13},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":12},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":9},{\"lvl\":7,\"data\":1000010,\"x\":16,\"y\":8},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":11},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":17,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":18,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":7},{\"lvl\":5,\"data\":1000013,\"x\":29,\"y\":21},{\"lvl\":5,\"data\":1000011,\"x\":17,\"y\":9},{\"lvl\":0,\"data\":1000015,\"x\":8,\"y\":11},{\"lvl\":8,\"data\":1000002,\"x\":33,\"y\":20,\"res_timer\":120217},{\"lvl\":5,\"data\":1000000,\"x\":28,\"y\":29},{\"lvl\":9,\"data\":1000006,\"x\":4,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":7},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":7},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":8},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":8},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":17},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":24,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":23,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":22,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":9},{\"lvl\":6,\"data\":1000010,\"x\":21,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":20,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":19,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":18,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":15},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":10},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":11},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":12},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":13},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":14},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":15},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":16},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":17},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":18},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":23},{\"lvl\":7,\"data\":1000010,\"x\":28,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":27,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":26,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":25,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":26},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":19},{\"lvl\":9,\"data\":1000008,\"x\":33,\"y\":17},{\"lvl\":9,\"data\":1000008,\"x\":8,\"y\":19},{\"lvl\":9,\"data\":1000009,\"x\":21,\"y\":16},{\"lvl\":5,\"data\":1000013,\"x\":12,\"y\":20},{\"lvl\":2,\"data\":1000023,\"x\":37,\"y\":24,\"res_timer\":40689},{\"lvl\":5,\"data\":1000012,\"x\":16,\"y\":24},{\"lvl\":3,\"data\":1000024,\"x\":25,\"y\":18},{\"lvl\":3,\"data\":1000026,\"x\":20,\"y\":4},{\"lvl\":0,\"data\":1000022,\"x\":25,\"y\":15},{\"lvl\":2,\"data\":1000028,\"x\":16,\"y\":17},{\"lvl\":0,\"data\":1000015,\"x\":16,\"y\":37},{\"lvl\":10,\"data\":1000005,\"x\":25,\"y\":12},{\"lvl\":10,\"data\":1000003,\"x\":13,\"y\":16},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":12,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":10,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":9,\"y\":27},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":8,\"y\":27},{\"lvl\":6,\"data\":1000010,\"x\":8,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":26},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":29,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":13,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":12,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":17,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":16,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":15,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":14,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":24,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":23,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":22,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":21,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":13,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":12,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":11,\"y\":19},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":20},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":21},{\"lvl\":6,\"data\":1000010,\"x\":11,\"y\":22},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":25},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":24},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":23},{\"lvl\":6,\"data\":1000010,\"x\":7,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":25},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":24},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":23},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":22},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":21},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":20},{\"lvl\":7,\"data\":1000010,\"x\":19,\"y\":19},{\"lvl\":7,\"data\":1000010,\"x\":20,\"y\":19},{\"lvl\":9,\"data\":1000009,\"x\":29,\"y\":17},{\"lvl\":5,\"data\":1000013,\"x\":21,\"y\":12},{\"lvl\":5,\"data\":1000012,\"x\":18,\"y\":16},{\"lvl\":5,\"data\":1000011,\"x\":25,\"y\":9},{\"lvl\":2,\"data\":1000023,\"x\":29,\"y\":7,\"res_timer\":40691},{\"lvl\":3,\"data\":1000026,\"x\":15,\"y\":4},{\"lvl\":1,\"data\":1000029,\"x\":25,\"y\":4}],\"obstacles\":[],\"last_news_seen\":155,\"last_league_rank\":13,\"newShopBuildings\":[4,0,6,3,6,3,4,1,5,5,225,3,3,4,1,5,0,0,0,3,1,0,1,2,1,0,2,0,1,1],\"newShopDecos\":[1,4,0,1,1,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}"}';
$data = json_decode($str,1);
$village = json_decode($data['villageJson'],1);
$randomVar = $village['buildings'];
print_r($randomVar);
You should use json_decode() to turn the string into an object.
PHP: json_decode - Manual

Trouble decoding Json from Google

Well, I'm trying to retrieve some info, from the Google Suggest tool.
The thing is, the json returned after the request, doesn't seem decode-able (using json_decode) + JSONLint sees it as "invalid".
What's wrong?
{
e: "GooDUs7lFIeXO63LgBA",
c: 0,
u: "https://www.google.com/s?gs_rn\x3d24\x26gs_ri\x3dpsy-ab\x26tok\x3dt8ORbtI13MEFLoCQjPSv6w\x26cp\x3d2\x26gs_id\x3d3i\x26xhr\x3dt\x26q\x3dtemplate\x26es_nrs\x3dtrue\x26pf\x3dp\x26safe\x3doff\x26sclient\x3dpsy-ab\x26oq\x3d\x26gs_l\x3d\x26pbx\x3d1\x26bav\x3don.2,or.r_cp.r_qf.\x26bvm\x3dbv.50500085,d.bGE\x26fp\x3dc513cf9c63a02102\x26biw\x3d1304\x26bih\x3d437\x26tch\x3d1\x26ech\x3d20\x26psi\x3dFYkDUs-xCsrT4QTD9YGwDw.1375963413783.1",
p: true,
d: "[\x22template\x22,[[\x22template\\u003cb\\u003es\\u003c\\/b\\u003e\x22,0],[\x22template\\u003cb\\u003e monster\\u003c\\/b\\u003e\x22,0],[\x22template\\u003cb\\u003e c++\\u003c\\/b\\u003e\x22,0],[\x22template\\u003cb\\u003es for pages\\u003c\\/b\\u003e\x22,0]],{\x22t\x22:{\x22bpc\x22:false,\x22tlw\x22:false},\x22q\x22:\x22YjrI_EdhVrEkZrkqZwaGIJ_Ih4c\x22,\x22j\x22:\x223i\x22}]"
}
That's what JSONLint gives as an error :
Parse error on line 1:
{ e: "GooDUs7lFIeXO63L
-----^
Expecting 'STRING', '}'
P.S. Even after editing it like "e": and so on, it still gives out error regarding the value of u and claiming that it was expecting a STRING or NUMBER etc... :S
The code given in the question is not valid JSON.
In order to be valid JSON, it would be required to have the field named in quotes. There are no quotes around the e variable name, or any of the others.
This is what the JSON decoder is complaining about: It is expecting to see "e", not e.
In addition, JSON does not accept the \x escaping format (character reference in hex); it can only use the \u format (unicode character reference in decimal). The code you've provided includes escaped characters in both formats.
The question is, are you using an official Google API? Because they're usually pretty good at providing valid JSON. This isn't valid JSON, so it may be that you're not using the correct API. Another clue is that the variable names aren't very meaningful; offical APIs would normally give more meaningful variable names. If it is the correct API, you should try raising a ticket with Google to fix it; broken JSON is not good, but it should be pretty trivial for them to fix.
Assuming you can't get them to fix it and we can't find an alternative API location that does give valid data, how do we deal with what we've got?
While this code may not be valid JSON, it is valid as a Javascript object (the JSON rules are stricter that those of plain Javascript). It could therefore be run in a Javascript interpreter using eval(), if you trusted it enough for that.
The only other alternativate is to fix the string prior to parsing it so that the variable names are quoted. That's a bit of a pain, but would be do-able if the output was consistent. You'll have problems though if it ever changes (and again, if it's an unofficial API, that could happen at any time without warning).
The problem is with the backslashes in the strings (used for the escape characters)
In PHP 5.4, you can use JSON_UNESCAPED_SLASHES:
echo json_encode(JSON_STRING, JSON_UNESCAPED_SLASHES);
Otherwise, you can do the replacement-
str_replace('\\/', '/', json_encode(JSON_STRING));
Since \/ is a valid way to represent /
OK, so this is what I ended up doing (not elegant at all but it works) :
$content = preg_replace_callback(
"(\\\\x([0-9a-f]{2}))i",
function($a) {return chr(hexdec($a[1]));},
$content
);
$content = str_replace("e:","\"e\":",$content);
$content = str_replace("c:","\"c\":",$content);
$content = str_replace("u:","\"u\":",$content);
$content = str_replace("p:","\"p\":",$content);
$content = str_replace("d:","\"d\":",$content);
$content = str_replace("\"[","[",$content);
$content = str_replace("]\"","]",$content);
$content = json_decode($content);

string delimiter ajax call

So a PHP file returns a string ( to an ajax call ) like this :
$output = $sessID."###".$sessEmail."###".$sessFirstName."###".$sessLanguage."###".$sessRememberMe;
and in javascript i do :
if (reply.indexOf("###") >= 0) {
arrayReply = reply.split("###");
user.ID = arrayReply[0];
user.Email = arrayReply[1];
user.FirstName = arrayReply[2];
user.Language = arrayReply[3];
user.RememberMe = arrayReply[4];
}
a problem can arise when parts of reply contain the the delimiter i use "###". What can I do in such a situation? Making the delimiter more complex/rare is not a solution in my opinion.
PS: I did try JSON but it's WAY SLOWER server side.
FINAL EDIT:
server side JSON is slower, and the same for client side, however it's not going to be a bottleneck ( 430ms for 100.000 calls ) and plus there is no need as Jules said below to re-invent the wheel. There was one more solution: bin2hex() in php [which reduced the time from 430ms to 240] and then get back the string in javascript with a hex2string function, however not worth the effort. JSON it is. Thank you all!
If as you say encoding as JSON is slower than you could try the following,
$output = '"' . some_kind_of_escape_function($sessID).'","'.some_kind_of_escape_function($sessEmail).'","'.some_kind_of_escape_function($sessFirstName).'","'.some_kind_of_escape_function($sessLanguage).'","'.$sessRememberMe.'"';
and of course replace some_kind_of_escape_function with the appropriate php function (e.g. addslashes or mysql_real_escape_string) it has been a while since I've done PHP development so choose the one that best suits your needs
Then it's a simple case of splitting by the comma and removing the quotes
One option is to use JSON object instead.
For PHP (using json_encode):
$output = json_encode(array(
"sessid" => $sessID,
"sessEmail" => $sessEmail,
"sessFirstName" => $sessFirstName,
"sessLanguage" => $sessLanguage,
"sessRememberMe" => $sessRememberMe
));
For JS (using jQuery method):
$.getJSON("/path/to/script.php", function(reply) {
user.ID = reply.sessid;
user.Email = reply.sessEmail;
user.FirstName = reply.sessFirstName;
user.Language = reply.sessLanguage;
user.RememberMe = reply.sessRememberMe;
});
Otherwise, you can use any other delimiter that possibly won't be found in the fields (or you can replace it throughout the fields). One of the examples is to use symbol of newline (\n).
Why develop your own format if there is already one?
use Json:
$output = json_encode(array('sessionID'=>$sessID,'sessionEmail'=>sessEmail,'sessionFirstName'=>$sessFirstName,'sessLanguage'=>$sessLanguage,'sessRememberMe'=>$sessRememberMe));
And for the Javsascript Side see
http://www.javascriptkit.com/dhtmltutors/ajaxgetpost4.shtml
or if your using JQuery etc. your Framework is much likely to have some kind of inbuild functionality such as http://api.jquery.com/jQuery.getJSON/
However if you want to use your ###-Delimiter i'd suggest you reduce it to just "#", for the sake of simplicity and space. After that introduce what is called an escape charater such as "\" So in a prepass you'll parse your input and replace all occurences of # with #, vice versa in the output. You can then Split your String using a special Regex, which only splits by # and not by "#"
You can use json.
http://php.net/manual/en/function.json-encode.php
How to JSON decode array elements in JavaScript?

PHP string contains $ and incorrectly recognizes variable

Basically I'm sending a formatted string to a PHP script via POST
So say I have the string... "abcdef$ghikl" it will recognize $ghikl as a variable...
Is there any ways to tell PHP that no variables exist within this string?
I know how to hard code it, you just use "'", but since the string is being sent to the script, I don't know what to do...
Thanks guys
For the scope of the question, all the code that's really needed is this:
$string = $_POST['string'];
// a couple strcmp's here, just to see if the string == ""
$array = explode("+", $string);
Try escaping the $
"abcdef\$ghikl"
PHP won't see that as a variable unless you eval() it. Can you show us your code?

PHP json_encode not returning valid json

I am running a Debian box with PHP v5.2.17. I am trying to get around the cross-domain issue with an XML file and am using this got to fetch any xml and return json:
<?php
header('content-type: application/json; charset=utf-8');
if( strlen($_GET["feed"]) >= 13 ) {
$xml = file_get_contents(urldecode($_GET["feed"]));
if($xml) {
$data = #simplexml_load_string($xml, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($data);
echo isset($_GET["callback"]) ? "{$_GET[’callback’]}($json)" : $json;
}
}
?>
The problem is, its not returning valid json to jquery.. The start character is "(" and the end is ")" where jquery wants "[" as the start and "]" as the end. I've taken the output and used several online validation tools to check it..
Is there a way I can change these characters prior to sending back or pass json_encode options?
You could change json_encode($data) to json_encode(array($data)) if it expects an array (like you're saying):
$json = json_encode(array($data));
EDIT: Also, I believe the SimpleXml call will result in a bunch of SimpleXmlElements, perhaps json_encode then thinks it should be objects, instead of arrays? Perhaps casting to an array will yield the correct results.
You cannot json_encode() SimpleXMLElements (that's the type that is returned by simplexml_load_string(). You have to convert the data from the XML file into some native PHP type (most likely an array).
SORRY that's wrong. json_encode() can in fact encode SimpleXMLElements (at least on my PHP version 5.3.4). So if your client-side code expects an array you must wrap your $data in an array:
$json = json_encode(array($data));
We can use json_encode() function most probably on array. so you first take XML content into PHP array and then apply json_encode().I think this will solve your problem..
It seems that you are sending an empty callback parameter or something, but the callback parameter in jQuery must look exactly like this: callback=?

Categories