I have a function that convert my inputs to base64 encode:
function goToMap()
{
$rows = $('.address');
$length_rows = $('.address').length;
$arr_objs = Array();
$rows.each( function(){
$obj = {};
$row_id = $(this).attr('data-id');
$obj.id = $row_id;
$obj.address = $('#address_'+$row_id).val();
$obj.type = $('#type_'+$row_id).val();
$obj.lat = $(this).attr('data-lat')
$obj.lnt = $(this).attr('data-lnt');
$arr_objs.push($obj);
});
$b4 = btoa($arr_objs);
location.href = 'http:/****/?b4='+$b4;
}
but when I convert my inputs to base64 with btoa
function, I can't convert it to pure json
with php
:
my base64 output:
W29iamVjdCBPYmplY3RdLFtvYmplY3QgT2JqZWN0XSxbb2JqZWN0IE9iamVjdF0=
after convert with php:
$all_address = json_decode(base64_decode($gets['b4']),true);
var_dump($all_address);
return;
output:
string(47) "[object Object],[object Object],[object Object]"
my json output of my function:
[
{
"id": "35",
"address": "تهران خیابان امام خمینی",
"type": "1",
"lat": "35.6886846123666",
"lnt": "51.387248933315284"
},
{
"id": "91",
"address": "تهران خیابان امام خمینی",
"type": "1",
"lat": "",
"lnt": ""
},
{
"id": "36",
"address": "کرج کوچه جعفری",
"type": "2",
"lat": "35.84001878731047",
"lnt": "50.93909069895744"
}
]