I'm tring to retrieve correct JSON from this code.
$query = array( 'loc' => array('$geoWithin' => array('$centerSphere' => array(array($x,$y), 35 / 6371) )));
$cursor = $collection->find($query);
// How many results found
$num_docs = $cursor->count();
if( $num_docs > 0 )
{
foreach($cursor as $doc['punti'])
echo json_encode($doc);
}
}
else
{
echo "NO LOCATION \n";
}
if i try to validate result in http://jsonlint.com/ it shows error.
i'll post the result of query:
{
"punti": {
"_id": {
"$id": "551fb585ecba12c819000032"
},
"nome": "Google",
"loc": [
-122.083983,
37.422969
],
"icona": 1,
"istituzione_id": {
"$id": "551fb556ecba12c819000031"
}
}
}{
"punti": {
"_id": {
"$id": "5520fe2becba12c003000029"
},
"nome": "Oracle",
"loc": [
-122.262168,
37.531595
],
"icona": 1,
"istituzione_id": {
"$id": "551fb556ecba12c819000031"
}
}
}
the error in JSONLint is about:
Parse error on line 16:
...1" } }}{ "punti": {
--------------------^
Expecting 'EOF', '}', ',', ']'
I've tried different ways, without reaching any solution.Can Someone help me ?
通过链接验证和共享数据的工具之一,请使用此工具进行验证;如果无效,请在此处共享或与您的朋友共享以获取帮助http://codebeautify.org/jsonvalidate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.