Reputation: 13
i've spend so many time in the net for learning google api v3 from php /mysql but no way.so i begin again asking for validate all the process First my json file, looks like that
{"lat":"46.8529510","lng":"0.5433920","ec_nom":"ANTRAN","ec_type":"ECOLE ELEM","ec_adresse":"PLACE DE L EGLISE","ec_ville":"ANTRAN","ec_cp":"86100"}
all the json file, i've seen looks like
**name[**{"lat":"46.8529510","lng":"0.5433920","ec_nom":"ANTRAN","ec_type":"ECOLE ELEM","ec_adresse":"PLACE DE L EGLISE","ec_ville":"ANTRAN","ec_cp":"86100"}**]**
My code
$cherch_coordon=mysql_query("SELECT lat, lng, ec_nom,ec_type,ec_adresse,ec_ville,ec_cp from mouv_0910 WHERE type_nomin='TD' AND oui_mouvement>0 ORDER BY ec_ville ");
$combien=mysql_num_rows($cherch_coordon) ;
while ($trouv=mysql_fetch_object($cherch_coordon))
{
$en_jason=json_encode($trouv) ;
//$erreur_json=last_error($en_jason);
echo"$en_jason" ;
So is my json file's valid?
Upvotes: 0
Views: 176
Reputation: 227310
json_encode
always prints valid JSON.
{}
is for an object, []
is for an array.
P.S.
name[{"lat":"46.8529510","lng":"0.5433920","ec_nom":"ANTRAN","ec_type":"ECOLE ELEM","ec_adresse":"PLACE DE L EGLISE","ec_ville":"ANTRAN","ec_cp":"86100"}]
Is not valid JSON, or vaid anything for that matter.
Did you mean this (note the ()
instead of []
)?
name({"lat":"46.8529510","lng":"0.5433920","ec_nom":"ANTRAN","ec_type":"ECOLE ELEM","ec_adresse":"PLACE DE L EGLISE","ec_ville":"ANTRAN","ec_cp":"86100"})
This is JSONP, not JSON.
Upvotes: 1