Passing JSON from MQTT into InfluxDB

Hello everyone,

I am running into problems sending my JSON data into InfluxDB. My JSON is being pulled in via MQTT in this format:

[
    {
        "measurement": "sensor data"
    },
    {
        "tags": {
            "location": "eic",
            "sensor": "sentry pro"
        }
    },
    {
        "time": 1566329777.4187512
    },
    {
        "fields": {
            "Temperature_F_Reference": [
                72.05
            ],
            "Time_Reference": [
                213.0
            ],
            "Real_Ohms_Working_1K": [
                67.659
            ],
            "Real_Ohms_Working_300": [
                89.2325
            ],
            "Working_Probe": [
                "Working"
            ],
            "Frequency_Working_1K": [
                1000.0
            ],
            "Cap_Working_300": [
                13.5837
            ],
            "Frequency_Working_300": [
                300.0
            ],
            "Img_Reference_300": [
                43.909
            ],
            "Real_Ohms_Reference_1K": [
                56.466
            ],
            "Img_Working_1K": [
                17.5842
            ],
            "Real_Ohms_Reference_300": [
                81.5604
            ],
            "Frequency_Reference_1K": [
                1000.0
            ],
            "Img_Working_300": [
                39.0554
            ],
            "Reference_Probe": [
                "Reference"
            ],
            "Cap_Working_1K": [
                9.051
            ],
            "Img_Reference_1K": [
                22.4024
            ],
            "Time_Working": [
                210.0
            ],
            "Temperature_F_Working": [
                72.05
            ],
            "Temperature_C_Working": [
                22.25
            ],
            "Cap_Reference_300": [
                12.0822
            ],
            "Frequency_Reference_300": [
                300.0
            ],
            "Temperature_C_Reference": [
                22.25
            ],
            "Cap_Reference_1K": [
                7.104
            ]
        }
    }
]

This is what the dubug is showing coming in after I decode the JSON.
image

This is what the flow looks like hooked up to the debug.

I am at a loss on what I need to adjust for the data to be accepted into InfluxDB.

Thanks for all of the help,

Derick

Can you post your flow to show how you decode the JSON? Based on the screenshot of the debug node it appears to create a JavaScript object as intended, then literally creates a string of it. So what you see in the payload is the string representation of an array with objects.

I read in a post, or was just under the assumption, that the JSON needed to be decoded first.

Is that what you are asking for? I am still learning how all of this works.

I think you are a little confused about what JSON is. JSON is a method of encoding a javascript object as a string, so JSON is already a string. What you want to do first is to convert it to a javascript object (if what you have to start with is actually JSON). If you feed the incoming data into a debug node it will tell you at the top whether it is a string or an object. If it is a string then feed it into a JSON node to convert it to a javascript object.

I realized i was using a mqtt node that parsed json data.

I am now using the mqtt dynamic node hooked up as follows with these outputs.

image

Set the mqtt node to a parsed json object.

Your field formats are a bit strange, all single values seem to live in an array, you will have to fix that first and then you can connect it to the influx batch node.
Then it should work.

Note that the timestamp needs to be nanoseconds for the influx batch node.

@Axiom do you have a solution for that?
i have the same issue