# \[FB-16471\] system.net.httpClient parses json ints as floats

**URL:** <https://forum.inductiveautomation.com/t/fb-16471-system-net-httpclient-parses-json-ints-as-floats/34637>\
**Category:** Ignition\
**Tags:** ignition80, scripting\
**Created:** [May 11, 2020, 8:46pm UTC](https://forum.inductiveautomation.com/t/fb-16471-system-net-httpclient-parses-json-ints-as-floats/34637 "2020-05-11T20:46:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.dolberg](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@peter.dolberg](https://forum.inductiveautomation.com/u/peter.dolberg)\
**Post date:** [May 11, 2020, 8:46pm UTC](https://forum.inductiveautomation.com/t/fb-16471-system-net-httpclient-parses-json-ints-as-floats/34637/1 "2020-05-11T20:46:40Z")

</div>

There is a difference in behavior between the JSON parsing done by the `system.net.httpClient()` response object and the `system.util.jsonDecode()` function. In particular, integers are always returned as floats from the `system.net.httpClient()` response JSON.

The code below, run on Ignition 8.0.11 and 8.0.12, shows how the two different JSON parsing approaches return different types:

```auto
client = system.net.httpClient()
response=client.get('https://httpbin.org/anything', data={'int':1}, headers={'accept': 'application/json'})
# prints <type 'float'>
print(type(response.json['json']['int'])) 
# prints <type 'int'>
print(type(system.util.jsonDecode(response.text)['json']['int'])) 

```

Is this behavior intended? The behavior of `system.util.jsonDecode()` seems to make more sense. At least for my use-case, it did exactly what I wanted it to.

Will it remain this way?

I’d like to be able to use `response.json` instead of always having to call `system.util.jsonDecode(response.text)` but this behavior means I’ll have to add several `int()` calls in my code to turn several float values into int values.

It may be a good idea to document this difference in behavior so people using `system.net.httpClient()` aren’t confused by how it parses JSON.

* * *

While I’m here, the [https://docs.inductiveautomation.com/display/DOC80/system.net.httpClient](https://docs.inductiveautomation.com/display/DOC80/system.net.httpClient) page is missing the name of the keyword argument `data` in the JythonHttpClient Methods \> Parameters section.

What is shown:

```auto
String or Dictionary or byte[] - Data to send in the request. [Optional. Defaults to None.]

```

What it should be

```auto
String or Dictionary or byte[] data - Data to send in the request. [Optional. Defaults to None.]

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 11, 2020, 8:56pm UTC](https://forum.inductiveautomation.com/t/fb-16471-system-net-httpclient-parses-json-ints-as-floats/34637/2 "2020-05-11T20:56:38Z")

</div>

It doesn’t look intentional to me, but I’ll have to open a ticket so we can investigate the consequences of changing the utility function responsible for this conversion.

---

<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 11, 2020, 9:41pm UTC](https://forum.inductiveautomation.com/t/fb-16471-system-net-httpclient-parses-json-ints-as-floats/34637/3 "2020-05-11T21:41:21Z")

</div>

> [@peter.dolberg](#):
>
> Is this behavior intended? The behavior of `system.util.jsonDecode()` seems to make more sense. At least for my use-case, it did exactly what I wanted it to.

Nope, and yeah, it should try to use an integer type if appropriate. We'll get that fixed.

> [@peter.dolberg](#):
>
> While I’m here, the [system.net.httpClient - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/system.net.httpClient) page is missing the name of the keyword argument `data` in the JythonHttpClient Methods \> Parameters section.

Fixed, good catch!
