I produce a json like this:

> 
> ["\"latitud\":\"123.0\",\"orden\":\"0\",\"longitud\":\"123.0\",\"urlfoto\":\"a\",\"idruta\":\"45\"}","{\"latitud\":\"321.0\",\"orden\":\"1\",\"longitud\":\"321.0\",\"urlfoto\":\"b\",\"idruta\":\"45\"}","{\"latitud\":\"231.0\",\"orden\":\"2\",\"longitud\":\"231.0\",\"urlfoto\":\"c\",\"idruta\":\"45\"}"]
> 
> 
> 

I search here and I have tryed:

```
$puntos = $_POST['puntos'];
$data = json_decode($puntos,true);

```

---

```
foreach($data as $obj) {
        $idruta = $obj['idruta'];
        $orden = $obj['orden'];
        $urlfoto = $obj['urlfoto'];
        $longitud = $obj['longitud'];
        $latitud = $obj['latitud'];
    }

```

Illegal string offset 'idruta'

---

```
foreach($data as $obj) {
         $idruta = $obj->idruta;
         $orden = $obj->orden;
         $urlfoto = $obj->urlfoto;
         $longitud = $obj->longitud;
         $latitud = $obj->latitud;
     }

```

Trying to get property of non-object

---

```
foreach($data as $obj) {
        $idruta = $obj[0];
        $orden = $obj[1];
        $urlfoto = $obj[2];
        $longitud = $obj[3];
        $latitud = $obj[4];
    }

```

obj[i] is always 0 and no errors.

The loop do 3 times so that's ok.

Sorry I'm just learning JSON and php, I will very glad if anybody can help me getting the data of the JSON. 

Thanks! 

**EDIT:** Thanks for the answers!
I don't know why is missing the "{" and when i paste the same json in JSONlint for example its validates fine so... I'm a little lost sorry.

That's the way I am sending the json:

```
public void insertPoints(ArrayList<Punto> puntos){
        JSONArray array = new JSONArray();
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        for(Punto p:puntos){
            JSONObject obj = new JSONObject();
            try {
            obj.put("idruta",Integer.toString(p.getIdruta()));
            obj.put("orden",Integer.toString(p.getOrden()));
            obj.put("urlfoto",p.getUrlfoto());
            obj.put("longitud",Double.toString(p.getLongitud()));
            obj.put("latitud",Double.toString(p.getLongitud()));
            array.put(obj.toString());
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        HttpClient httpClient = new DefaultHttpClient();

        try {
            HttpPost request = new HttpPost(CREATE_POINT);
            StringEntity params =new StringEntity("puntos=" + postjson);
            request.addHeader("content-type", "application/x-www-form-urlencoded");
            request.setEntity(params);
            HttpResponse response = httpClient.execute(request);
            // handle response here...

        } catch (Exception ex) {
            // handle exception here
        } finally {
            httpClient.getConnectionManager().shutdown();
        }
        }

```

is here any problem?

Thanks!