Skip to main content

message.putJson

message.putJson(key, value)

Description

Parses and inserts a json structure into the message at the key.

Parameters

ParameterTypeExplanation
keyStringField name (use a / between field names when the field is within another field)
valueObjectThe json value to set the field to

Example

json = '''{
"metric_name": "network_in",
"value": 1200,
"unit": "KBps",
"timestamp": "2024-07-15T12:35:10Z",
"tags": {
"host": "server01",
"environment": "prduction",
"region": "us-west",
"external_ip": "203.0.113.42"
}
}'''

msg = api.newMessage("metric")
msg.putJson("body", json)
api.publish(msg)