Using $json to put the whole JSON response into Body, but there is an extra [object:

Hi, sorry if it is a stupid question. I am trying to use the JSON response from previous node and put into the body of a HTTP call.

The JSON response from INPUT is like this:

[
    {
        "target": "HAlbab7tFBNezyd5nFq3RA",
        "mapping": {
            "properties": {
                "firstName": {
                    "valueProvider": {
                        "source": {
                            "id": "HJekVeSkBWjUotd84TzH8w",
                            "type": "schema",
                            "path": "$.FirstName"
                        },
                        "transformations": []
                    }
                },
                "lastName": {
                    "valueProvider": {
                        "source": {
                            "id": "HJekVeSkBWjUotd84TzH8w",
                            "type": "schema",
                            "path": "$.LastName"
                        },
                        "transformations": []
                    }
                },
                "ciamId": {
                    "items": {
                        "valueProvider": {
                            "source": {
                                "id": "HJekVeSkBWjUotd84TzH8w",
                                "type": "schema",
                                "path": "$.ContactID"
                            },
                            "transformations": []
                        }
                    }
                }
            }
        }
    }
]

I used {{$json}} to put the whole JSON into my node body, however it returns like this:
[Object: {“target”: “HAlbab7tFBNezyd5nFq3RA”, “mapping”: {“properties”: {“firstName”: {“valueProvider”: {“source”: {“id”: “HJekVeSkBWjUotd84TzH8w”, “type”: “schema”, “path”: “$.FirstName”}, “transformations”: }}, “lastName”: {“valueProvider”: {“source”: {“id”: “HJekVeSkBWjUotd84TzH8w”, “type”: “schema”, “path”: “$.LastName”}, “transformations”: }}, “ciamId”: {“items”: {“valueProvider”: {“source”: {“id”: “HJekVeSkBWjUotd84TzH8w”, “type”: “schema”, “path”: “$.ContactID”}, “transformations”: }}}}}}]

My question is how can I get rid of the Object that populated into my JSON? I just want to keep the JSON as the input.

Thanks a lot.

Regards,
Kai

Hey @Kai_C hope all is well, welcome to the community.

Try
{{ JSON.stringify($json) }}

Hi I tried as well, it become :

{"target":"HAlbab7tFBNezyd5nFq3RA","mapping":{"properties":{"firstName":{"valueProvider":{"source":{"id":"HJekVeSkBWjUotd84TzH8w","type":"schema","path":"$.FirstName"},"transformations":[]}},"lastName":{"valueProvider":{"source":{"id":"HJekVeSkBWjUotd84TzH8w","type":"schema","path":"$.LastName"},"transformations":[]}},"ciamId":{"items":{"valueProvider":{"source":{"id":"HJekVeSkBWjUotd84TzH8w","type":"schema","path":"$.ContactID"},"transformations":[]}}}}}}

which missing the starting .

Maybe [{{ JSON.stringify($json) }}] then?

1 Like

Yea that works! Im obviously an idiot to overlook that! Thanks a lot

This is just the way n8n renders the object in the ide. The data will still be correct in the http call.