---
title: Creating responses in JSON format
description: "In case when Gate HTTP module works as Listener, there is a possibility that its response has to be in JSON type. Assuming that the sent response looks like: There is a need to create the following sc"
---

[Skip to content](https://knowledgebase.grenton.com/en/gate-http-creating-responses-in-json-format#main-content)

English

Show submenu for translations

[New ticket](https://knowledgebase.grenton.com/en/kb-tickets/new?hsLang=en) [Customer portal](https://knowledgebase.grenton.com/wsparcie?hsLang=en)

![Logo\_Grenton\_Main\_2020\_RGB\_v1.0-1.png\]](https://knowledgebase.grenton.com/hs-fs/hubfs/Logo_Grenton_Main_2020_RGB_v1.0-1.png?width=200&height=94&name=Logo_Grenton_Main_2020_RGB_v1.0-1.png)

Open main navigation

Close main navigation

- English
  
  Show submenu for translations
- [New ticket](https://knowledgebase.grenton.com/en/kb-tickets/new)
- [Customer portal](https://knowledgebase.grenton.com/wsparcie)
- [Trainings](https://www.grenton.com/cooperation/trainings.html)

[Trainings](https://www.grenton.com/cooperation/trainings.html)

 Hello. How can we help you?

- There are no suggestions because the search field is empty.

1. [Knowledge Base](https://knowledgebase.grenton.com/en?hsLang=en)
2. [Manuals](https://knowledgebase.grenton.com/en/manuals?hsLang=en)
3. [Gate HTTP](https://knowledgebase.grenton.com/en/manuals?hsLang=en#gate-http)

# Creating responses in JSON format

In case when Gate HTTP module works as Listener, there is a possibility that its response has to be in JSON type.

Assuming that the sent response looks like:  
![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35132627877original0f052M0DWSp3rCCcxJgompclrjGy94sqWw-3.png)

There is a need to create the following script on Gate HTTP module:

```
local resp = {body=, {sensor_2_inside={value=21.8}}}}Gate_HTTP->Listener_JSON->SetResponseBody(resp)Gate_HTTP->Listener_JSON->SendResponse()
```

which has to be assigned to *OnRequest* event in *HttpListener* virtual object:

![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35132628578originalSXahDLDWyj10rAffLYXUmjlBc25eOIzVzA-3.png)

In case when the returned parameter contains in its name the "." character:

![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35132627876originalt1Q3x3c2UAEnDo12zVTzoVyWL6UlCnYYoA-3.png)

The script assigned to *OnRequest *event in HttpListener virtual object should look like follows:

```
local resp = {}resp.body = {}resp.body[1] = {}resp.body[1]["sensor.1.outside"] = {}resp.body[1]["sensor.1.outside"]["value"] = 17.2resp.body[2] = {}resp.body[2]["sensor.2.inside"] = {}resp.body[2]["sensor.2.inside"]["value"] = 21.8Gate_HTTP->Listener_JSON->SetResponseBody(resp)Gate_HTTP->Listener_JSON->SendResponse()
```

 

![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/support.grenton.plensupportsolutionsarticles35000177207-gate-http-creating-responses-in-json-formathit-2.gif)

- [Installation guidelines](https://knowledgebase.grenton.com/en/installation-guidelines?hsLang=en#main-content)

    - [How to Prepare Electrical Installation](https://knowledgebase.grenton.com/en/installation-guidelines?hsLang=en#how-to-prepare-electrical-installation)
- [Reference devices](https://knowledgebase.grenton.com/en/reference-devices?hsLang=en#main-content)

    - [Integrated Device](https://knowledgebase.grenton.com/en/reference-devices?hsLang=en#integrated-device)
- [Most Common Mistakes](https://knowledgebase.grenton.com/en/most-common-mistakes?hsLang=en)
- [Electrical Installation](https://knowledgebase.grenton.com/en/electrical-installation?hsLang=en)
- [Manuals](https://knowledgebase.grenton.com/en/manuals?hsLang=en#main-content)

    - [Gate Modbus](https://knowledgebase.grenton.com/en/manuals?hsLang=en#gate-modbus)
    - [Training](https://knowledgebase.grenton.com/en/manuals?hsLang=en#training)
    - [SW Applications](https://knowledgebase.grenton.com/en/manuals?hsLang=en#sw-applications)
    - [Gate HTTP](https://knowledgebase.grenton.com/en/manuals?hsLang=en#gate-http)
    - [Smart Panel](https://knowledgebase.grenton.com/en/manuals?hsLang=en#smart-panel)
    - [Configuration](https://knowledgebase.grenton.com/en/manuals?hsLang=en#configuration)
    - [myGrenton interfaces](https://knowledgebase.grenton.com/en/manuals?hsLang=en#mygrenton-interfaces)
    - [Virtual Objects](https://knowledgebase.grenton.com/en/manuals?hsLang=en#virtual-objects)
    - [Gate Alarm](https://knowledgebase.grenton.com/en/manuals?hsLang=en#gate-alarm)
- [Intercom](https://knowledgebase.grenton.com/en/intercom?hsLang=en)
- [FAQ](https://knowledgebase.grenton.com/en/faq?hsLang=en#main-content)

    - [FAQ](https://knowledgebase.grenton.com/en/faq?hsLang=en#faq)
    - [About Grenton](https://knowledgebase.grenton.com/en/faq?hsLang=en#about-grenton)
- [Price list and documents](https://knowledgebase.grenton.com/en/price-list-and-documents?hsLang=en)

[![Grenton logo](https://knowledgebase.grenton.com/hs-fs/hubfs/Logo_Grenton_variants_BIG_2020_plus_RGB_v0.2-02.png?width=400&height=100&name=Logo_Grenton_variants_BIG_2020_plus_RGB_v0.2-02.png "Grenton logo")](http://grenton.com)

<https://www.facebook.com/grenton.smart.home> <https://www.instagram.com/grenton_smart_home/> <https://www.youtube.com/channel/UCFNNI-dgO1cm81kCrSr1bzg> <https://www.linkedin.com/company/grenton>

Copyright © 2026, Grenton Sp.z o.o.