# Change JSON field type to allow JSONC

**URL:** <https://discourse.nodered.org/t/change-json-field-type-to-allow-jsonc/36716>\
**Category:** Feature Requests\
**Created:** [29 November 2020 14:59 UTC](https://discourse.nodered.org/t/change-json-field-type-to-allow-jsonc/36716 "2020-11-29T14:59:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 November 2020 14:59 UTC](https://discourse.nodered.org/t/change-json-field-type-to-allow-jsonc/36716/1 "2020-11-29T14:59:57Z")

</div>

Hi, sorry if this has been asked for previously.

It would be **really** useful if the JSON input field were changed to allow JSONC (JSON with comments).

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e276a9a5102dc8a820b73d7ab0317f504275fdc0.png)

Here is an example of JSONC:

```auto
{
    "topic": "Optional. Can be anything",
    "_uib": { // Required
        // This is a pseudo ref, you don't have to actually put it in your HTML
        "componentRef": "globalNotification",
        // Optional.
        "options": {
            "title": "Notification Title", // Optional. String or HTML.
            "content": "Optional. A string. Will appear second in the resulting pop-up. Can be HTML.",
            "append": false, // Optional. If TRUE, new notifications are added to the END of the list instead of the start.
            "autoHideDelay": 500, // Optional. If set, must be the number of milliseconds to display the notification.
            // Other Toasts options may also be included, see the bootstrap-vue and bootstrap documentation for details.
        }
    },
    "payload": "Optional. A string. Will appear first in the resulting pop-up. Can be HTML."
}

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [29 November 2020 15:51 UTC](https://discourse.nodered.org/t/change-json-field-type-to-allow-jsonc/36716/2 "2020-11-29T15:51:02Z")

</div>

> [@Formatted Function Node with separate JS files](https://discourse.nodered.org/t/formatted-function-node-with-separate-js-files/1760):
>
> I'm a big Node-Red fan, and I use it everyday. We use the "Projects" feature, and use GitHub to manage version control of our flows. The PrettyPrint setting has given us the ability to curate changes, but we also write a number of custom functions. Within a flows\_\*.json file, the contents of a function have the line feeds (\n) escaped. As a result Github can't discern changes line changes within a Node-Red function in a diff. If a Node-Red function node was changed, the entire "func:" field is…

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 November 2020 22:51 UTC](https://discourse.nodered.org/t/change-json-field-type-to-allow-jsonc/36716/3 "2020-11-29T22:51:44Z")

</div>

Thanks for the reminder though that was really dealing with flow files in the end wasn't it?

What I'm thinking of here is just for JSON input field. JSONC is a pretty well established format and simply allows comments to be added to JSON.

That wouldn't have any impact on the running or structure of Node-RED I don't think?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [29 November 2020 23:00 UTC](https://discourse.nodered.org/t/change-json-field-type-to-allow-jsonc/36716/4 "2020-11-29T23:00:11Z")

</div>

But it would break every node that parses the field expecting it to be JSON.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 November 2020 23:02 UTC](https://discourse.nodered.org/t/change-json-field-type-to-allow-jsonc/36716/5 "2020-11-29T23:02:50Z")

</div>

Seems my brain had got ahead of itself - I was thinking that there would be a difference between the input and the output. Rather like what happens with JSONata. So that the comments would be stripped from the input before outputting to the flow.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 January 2021 23:02 UTC](https://discourse.nodered.org/t/change-json-field-type-to-allow-jsonc/36716/6 "2021-01-28T23:02:50Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
