# Using HTTP Get and trying to parse the data as JSON

**URL:** <https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [May 21, 2026, 3:01pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641 "2026-05-21T15:01:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![kent](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@kent](https://forum.inductiveautomation.com/u/kent)\
**Post date:** [May 21, 2026, 3:01pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/1 "2026-05-21T15:01:55Z")

</div>

I am trying to pull some data from a Vorne XL system. I have the HTTP Get setup as a gateway script using system.net.httpClient and working. I format the return as JSON but there is a nested list with the info I actually want. I am still learning scripting, so what is a good way to pull out the variable in the list. Currently it is the [[u'running']] status but changes a lot so I can't just look for that text.

```python
{'data': {'events': [[u'running']]}, 'meta': {'device_id': u'MAC', 'data_version': u'1.6', 'asset_id': u'id'}}

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [May 21, 2026, 3:09pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/2 "2026-05-21T15:09:22Z")

</div>

Assuming you have it a variable called `payload` and you turned it into a dictionary with `system.util.jsonDecode`

```python
events = payload['data']['events'] # this will give you the list of lists
firstEvent = events[0]

```

Seems like you could get multiple events since they're sending you a list of lists so you could do different logic on the events variable to see if any of those inner lists have running or what have you.

In python use the keys to access the value. For instance getting the device Id is simple as

```python
deviceId = payload['meta']['device_id']

```

---

<div class="post-metadata">

**Author:** ![kent](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@kent](https://forum.inductiveautomation.com/u/kent)\
**Post date:** [May 21, 2026, 3:53pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/3 "2026-05-21T15:53:08Z")

</div>

Thank you. I was able to pull out the first item in the list, convert to string, then just slice out the 'u' character that it adds to all the entries.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 21, 2026, 4:07pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/4 "2026-05-21T16:07:51Z")

</div>

> [@kent](#):
>
> hen just slice out the 'u'

Any time you find yourself doing this ridiculous operation, it means somewhere you've turned an object into a string with jython `repr()`, which show unicode strings with that prefix.

**Don't stringify objects!**

`system.net.httpClient` will interpret JSON payloads for you and deliver the payload as a proper jython hierarchy of dictionaries, lists, and primitive elements. Just access them that way instead of playing fragile games with strings.

---

<div class="post-metadata">

**Author:** ![kent](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@kent](https://forum.inductiveautomation.com/u/kent)\
**Post date:** [May 21, 2026, 4:30pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/5 "2026-05-21T16:30:33Z")

</div>

That is how it's showing up after just using the .json attribute of the httpClient on the response. Not sure if I'm doing it wrong or if it's the response structure from the Vorne system.

---

<div class="post-metadata">

**Author:** ![Brian\_Seater](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brian_seater/32/82110_2.png) [@Brian\_Seater](https://forum.inductiveautomation.com/u/Brian_Seater)\
**Post date:** [May 21, 2026, 4:45pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/6 "2026-05-21T16:45:13Z")

</div>

I have seen cases where an API wraps a value in an extra sets of quotes, so the `response.json` call results in the inner string and you have to do another call to `system.util.jsonDecode()` to get it into a dictionary/list.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 21, 2026, 4:58pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/7 "2026-05-21T16:58:40Z")

</div>

> [@kent](#):
>
> **showing up** after just using the .json attribute

"Showing up" means some form of printing, which is stringification, and collapses the object structure.

Log `type(response.json)` to see what I mean. The `.json` attribute is documented to return an object, not a string, as long as the API provided the proper Content-Type header.

---

<div class="post-metadata">

**Author:** ![kent](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@kent](https://forum.inductiveautomation.com/u/kent)\
**Post date:** [May 21, 2026, 5:04pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/8 "2026-05-21T17:04:10Z")

</div>

Doing a `print type(response.json)` and then checking wrapper.log shows it as dictionary

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 21, 2026, 5:09pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/9 "2026-05-21T17:09:36Z")

</div>

Then access its elements with dictionary syntax, and inner elements per their types.

If you share the formatted JSON that actually gets delivered, we can help.

Or log `system.util.jsonEncode(response.json, 2)`. (You'll have to extract from the `wrapper.log` to get the properly indented result.)

---

<div class="post-metadata">

**Author:** ![kent](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@kent](https://forum.inductiveautomation.com/u/kent)\
**Post date:** [May 21, 2026, 5:31pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/10 "2026-05-21T17:31:17Z")

</div>

Here is everything,

```python
#set the client
	client = system.net.httpClient()
	# Set up the request for Monoblock status info
	MBstatusRequest = client.get("http://x.x.x.x/api/v0/channels/process_state/events/current?fields=process_state")
	#print the status request, a code of 200 at the end means Vorne saw a valid request
	print MBstatusRequest
	MBstatusData = MBstatusRequest.json
	print MBstatusData
	print system.util.jsonEncode(MBstatusRequest.json, 2)

```

The log for printing just the request

```python
<Response@5393670 'http://x.x.x.x/api/v0/channels/process_state/events/current?fields=process_state' [200]>

```

The log for printing with `request.json`

```python
{'data': {'events': [[u'running']]}, 'meta': {'device_id': u'nnn', 'data_version': u'1.6', 'asset_id': u'nnn'}}

```

The log for printing using `system.util.jsonEncode()`

```python
 {
   "data": {"events": [["running"]]},
   "meta": {
     "asset_id": "nnn",
     "data_version": "1.6",
     "device_id": "nnn"
   }
 }

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 21, 2026, 5:50pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/11 "2026-05-21T17:50:06Z")

</div>

So, the target you want should be `response.json['data']['events'][0][0]`. The list of lists at `events` is a bit odd. You may actually have to iterate through inner or outer lists depending on the variety in the responses.

Also, calling `system.net.httpClient()` on every API call is very expensive, and will leak memory. You should establish the client instance in a top level variable of a project library script (outside any `def`) and re-use it in the function called from your event.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 21, 2026, 6:07pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/12 "2026-05-21T18:07:19Z")

</div>

> [@pturmel](#):
>
> Also, calling `system.net.httpClient()` on every API call is very expensive, and will leak memory. You should establish the client instance in a top level variable of a project library script (outside any `def`) and re-use it in the function called from your event.

Or, if you're on 8.3+ (and don't need to customize the http client instance):

```python
MBstatusRequest = system.net.httpClient.get("http://x.x.x.x/api/v0/channels/process_state/events/current?fields=process_state")
#print the status request, a code of 200 at the end means Vorne saw a valid request
print MBstatusRequest
MBstatusData = MBstatusRequest.json
print MBstatusData
print system.util.jsonEncode(MBstatusRequest.json, 2)

```

---

<div class="post-metadata">

**Author:** ![kent](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@kent](https://forum.inductiveautomation.com/u/kent)\
**Post date:** [May 21, 2026, 6:10pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/13 "2026-05-21T18:10:15Z")

</div>

Yes, I am on 8.3. So I don't need to do it in the project library? I initially thought to put it in the gateway events as a scheduled script every minute or two, and to write the result to a memory tag. That way every open client isn't running the script.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 21, 2026, 6:12pm UTC](https://forum.inductiveautomation.com/t/using-http-get-and-trying-to-parse-the-data-as-json/115641/14 "2026-05-21T18:12:39Z")

</div>

As of 8.3.0, `system.net.httpClient` is both an instance of JythonHttpClient **and** the factory method to create new client instances (precisely to avoid the memory/resource leak Phil talked about).

So moving to the project library in this case is less mandatory than Phil suggests, though may still be worth it for the sake of encapsulation.
