# Retrieve online JSON data

**URL:** https://discourse.processing.org/t/retrieve-online-json-data/2784
**Category:** Beginners
**Created:** [August 20, 2018, 10:34am UTC](https://discourse.processing.org/t/retrieve-online-json-data/2784 "2018-08-20T10:34:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mloiz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mloiz/32/11462_2.png) [@mloiz](https://discourse.processing.org/u/mloiz)
#### Post date: [August 20, 2018, 10:34am UTC](https://discourse.processing.org/t/retrieve-online-json-data/2784/1 "2018-08-20T10:34:50Z")

</div>

Hello,  
I would like to retrieve some online JSON data, and I dont manage.  
first, I cannont print the row data ;  
then, what are the equivalents of `getJSONObject` and `getJSONArray` from Processing ?  
Indeed I have to go at this path _facet\_counts\>facet\_fields_

```auto
var jsonData;

function preload() {
	var codeLab = '15218';
	var url = 'https://api.archives-ouvertes.fr/search/?q=*:*&rows=0&facet=true&facet.field=structHasAuthIdHal_fs&facet.prefix=' +
		codeLab + '_&wt=json&facet.limit=30';
	jsonData = loadJSON(url);
}

function setup() {
	noLoop();
}

function draw() {
	print(jsonData); // return only [object Object]
        // go to this array : to facet_counts>facet_fields position>structHasAuthIdHal_fs
}

```

my goal is to translate [this](https://discourse.processing.org/t/iterate-throw-json-array-values/1710/2?u=mloiz) Processing sketch.  
thanks.

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [August 20, 2018, 10:47am UTC](https://discourse.processing.org/t/retrieve-online-json-data/2784/2 "2018-08-20T10:47:10Z")

</div>

Some online JSON sketches I’ve got for p5.js: 🤠

1. [Bl.ocks.org/GoSubRoutine/5fbc03e019c53254a2ba7e7fd3318b45](http://Bl.ocks.org/GoSubRoutine/5fbc03e019c53254a2ba7e7fd3318b45)
2. [Bl.ocks.org/GoSubRoutine/7a567f0510b338b6d0fc1ef53f24f10e](http://Bl.ocks.org/GoSubRoutine/7a567f0510b338b6d0fc1ef53f24f10e)
3. [Bl.ocks.org/GoSubRoutine/9aa9cd00000e331612c8e557b5dd28f0](http://Bl.ocks.org/GoSubRoutine/9aa9cd00000e331612c8e557b5dd28f0)

[https://api.Archives-Ouvertes.fr/search/?q=_:_&rows=0&facet=true&facet.field=structHasAuthIdHal\_fs&facet.prefix=\_&wt=json&facet.limit=30](https://api.Archives-Ouvertes.fr/search/?q=*:*&rows=0&facet=true&facet.field=structHasAuthIdHal_fs&facet.prefix=_&wt=json&facet.limit=30)

```auto
{
  "response": {
    "numFound": 1608268,
    "start": 0,
    "docs": []
  },
  "facet_counts": {
    "facet_queries": {},
    "facet_fields": {
      "structHasAuthIdHal_fs": []
    },
    "facet_ranges": {},
    "facet_intervals": {},
    "facet_heatmaps": {}
  }
}

```

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [August 20, 2018, 11:08am UTC](https://discourse.processing.org/t/retrieve-online-json-data/2784/3 "2018-08-20T11:08:47Z")

</div>

> [@mloiz](#):
>
> …, what are the equivalents of **getJSONObject()** and **getJSONArray()** from Processing?

1. **getJSONObject()**: use the dot `.` accessor operator, followed by the name of the property:  
`const num = jsonObj.response.numFound;`
2. **getJSONArray()**: use the brackets `[]` accessor operator, plus the desired index:  
`const gotId4 = jsonObj.facet_counts.facet_fields.structHasAuthIdHal_fs[3];`

---

<div class="post-metadata">

### Author: ![mloiz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mloiz/32/11462_2.png) [@mloiz](https://discourse.processing.org/u/mloiz)
#### Post date: [August 20, 2018, 3:37pm UTC](https://discourse.processing.org/t/retrieve-online-json-data/2784/4 "2018-08-20T15:37:07Z")

</div>

> [@mloiz](#):
>
> first, I cannont print the row data ;

this was because I used the [openprocessing.org](http://openprocessing.org) online eitor ; now it works fine with local files.

no pb for the dot and brackets accessor : thanks.
