# PoseNet + Processing Error: JSONArray\[0\] is not a JSONObject

**URL:** <https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302>\
**Category:** Libraries\
**Created:** [September 30, 2019, 4:38am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302 "2019-09-30T04:38:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![QueenBee](https://avatars.discourse-cdn.com/v4/letter/q/a9adbd/32.png) [@QueenBee](https://discourse.processing.org/u/QueenBee)\
**Post date:** [September 30, 2019, 4:38am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/1 "2019-09-30T04:38:45Z")

</div>

Hi!

I’ve been following Daniel Shiffman’s Runway tutorial on using PoseNet with processing (as an alternative to the ever finnicky Kinect!)

[![](https://img.youtube.com/vi/7btNir5L8Jc/maxresdefault.jpg "Introduction to Runway: Machine Learning for Creators (Part 2)") ](https://www.youtube.com/watch?v=7btNir5L8Jc)

I’m getting the following error right at the end of the tutorial:

**RuntimeException: JSONArray[0] is not a JSONObject.**

Even though I’ve checked over the code a couple times and it’s the exact same as what is done in the tutorial!

The code is as follows, the third line is what is highlighted in the error:

```auto
 if (data != null){
    JSONArray poses = data.getJSONArray("poses");
    ***JSONArray keypoints = poses.getJSONObject(0).getJSONArray("keypoints");***
    JSONObject nose = keypoints.getJSONObject(0);
    JSONObject nosePos = nose.getJSONObject("position");
    float x = nosePos.getFloat("x");
    float y = nosePos.getFloat("y");
    fill(255,0,0);
    ellipse(x,y,20,20);
  }

```

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [September 30, 2019, 1:09pm UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/2 "2019-09-30T13:09:15Z")

</div>

-a- can you link to where you get the code from?

-b- if the data contain array or object  
you can only find out by printing the content

-c- yes, and if we talk about the same structure of data,  
[https://github.com/runwayml/processing/blob/master/posenet/posenet.pde#L97](https://github.com/runwayml/processing/blob/master/posenet/posenet.pde#L97) ,  
indicates it is data.array.array  
while you ask for data.array.object.array  
but that is all guessing as i not know if we talk about the same data / project / code …  
still it would fit to the error msg. you get.

---

<div class="post-metadata">

**Author:** ![QueenBee](https://avatars.discourse-cdn.com/v4/letter/q/a9adbd/32.png) [@QueenBee](https://discourse.processing.org/u/QueenBee)\
**Post date:** [October 1, 2019, 12:46am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/3 "2019-10-01T00:46:39Z")

</div>

Yes, so the code is from the coding train video above - he didn’t link a github version this time so it’s just word-for-word re-written off the video.

He did use the example you linked, but opted to write new code for that segment to isolate each body part using the data.array.object.array format

I don’t know why it works for him and not for me? Haha. Anyway, I don’t fully understand how to isolate key body points in the example given by runway (the one you linked).

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 1, 2019, 3:26am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/4 "2019-10-01T03:26:08Z")

</div>

as i say, check on the DATA,  
( after learn the basics of JSON )  
we have no code, no data, no printout.

---

<div class="post-metadata">

**Author:** ![QueenBee](https://avatars.discourse-cdn.com/v4/letter/q/a9adbd/32.png) [@QueenBee](https://discourse.processing.org/u/QueenBee)\
**Post date:** [October 1, 2019, 5:11am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/5 "2019-10-01T05:11:42Z")

</div>

I’m sorry I don’t understand.

Earlier in the tutorial this line of code is used to develop the code above:

```auto
data = parseJSONObject(dataString);
 println(data);

```

and the “keypoints”… “poses”… the name of the point (eg. nose) and a whole lot of numbers does print to the console just like in the tutorial… Is this not the data?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 1, 2019, 5:16am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/6 "2019-10-01T05:16:44Z")

</div>

good,  
and what does it say?  
[]  
says it has a array  
{ }  
says it has a object …

* * *

[https://www.w3schools.com/js/js\_json\_objects.asp](https://www.w3schools.com/js/js_json_objects.asp)  
[https://www.w3schools.com/js/js\_json\_arrays.asp](https://www.w3schools.com/js/js_json_arrays.asp)

---

<div class="post-metadata">

**Author:** ![QueenBee](https://avatars.discourse-cdn.com/v4/letter/q/a9adbd/32.png) [@QueenBee](https://discourse.processing.org/u/QueenBee)\
**Post date:** [October 1, 2019, 7:00am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/7 "2019-10-01T07:00:04Z")

</div>

If you head to 19:25 in the video linked above you’ll see that I’ve done exactly what Shiffman has done - So I’m still confused as to why this matters

Why would the code need to be so different for me when I’m using the exact same programs and running it the same way? Why would me using a JSON object at this point be any different to him?

I’d note also that the tutorial was posted less than 2 months ago, so it can’t really be an outdated command…?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 1, 2019, 7:32am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/8 "2019-10-01T07:32:05Z")

</div>

did you read the Comments on the video page?

```auto
abc def
1 week ago
JSONArray[0] not found
2
Haylee
6 days ago
same error :/
...

Kejia Dai
1 month ago
I followed the tutorial and wrote the processing program, but the data structure I received from runway/posenet is different from the video.
Mine only has "scores" and "poses", no lable like "parts","posiciton" or "keypoints". And all the numbers in the "poses" array are pretty small like 0.3 or 0.5,
nothing lookis like coordinates. Is this because there is a new version of PosNet? Is there anyone with the same problem?
1
Jakov Ratkovic
1 month ago
have the same issue
i think its a bug cause you can still acces the objects trough the names

```

so, no other way!  
analyze the data you get!

---

<div class="post-metadata">

**Author:** ![QueenBee](https://avatars.discourse-cdn.com/v4/letter/q/a9adbd/32.png) [@QueenBee](https://discourse.processing.org/u/QueenBee)\
**Post date:** [October 4, 2019, 3:09am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/9 "2019-10-04T03:09:40Z")

</div>

Ah. I did glance at the comments but only very briefly - didn’t notice any negative ones! Thankyou.  
Might just have to keep digging.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 4, 2019, 4:07am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/10 "2019-10-04T04:07:45Z")

</div>

> [@QueenBee](#):
>
> Might just have to keep digging.

yes, sorry,

what i not understand is that you avoid

- to post your full code so someone ?with camera? can run it
- to post the result of

```auto
println(data);

```

OR

```auto
println(dataString);

```

so we see the _ **obviously changed** _ { […] } structure

i can not promise anything, but why not give someone a chance to help???

---

<div class="post-metadata">

**Author:** ![QueenBee](https://avatars.discourse-cdn.com/v4/letter/q/a9adbd/32.png) [@QueenBee](https://discourse.processing.org/u/QueenBee)\
**Post date:** [October 14, 2019, 6:56am UTC](https://discourse.processing.org/t/posenet-processing-error-jsonarray-0-is-not-a-jsonobject/14302/11 "2019-10-14T06:56:58Z")

</div>

Sorry, I was under the impression that we weren’t supposed to paste the full code - lesson learned.

I’ve decided to just use the kinect as I have it working (and I know how to pull specific joints!). With a limited timeframe PoseNet will have to wait until another project.  
Thankyou though.
