Key-Value Pairs and numeric fields

View thread

nimaimalle

From this example, in the docs: Name=Mike, Weight=64, Age=24, Pet=dog, Height=172

The sample shows accessing the fields like this, effectively casting certain values to integers: if ( integer($Weight) > integer($Height) - 100 )

However, I am using parse_kvp on data that I don't necessarily know the format of, then converting the data into JSON. In JSON, all of the values are quoted, including numeric ones. I need the numeric fields to be unquoted in JSON.

Is there a way to iterate through all fields in an Exec statement? I could test for numeric values and reassign them, casting to integer or float (but I don't think there's a float type)

I also thought about transforming the JSON string with s/"([0-9.]+)"/$1/g but this sort of regex is not yet supported in nxlog.

Any suggestions how to take Name=Mike, Weight=64, Age=24, Pet=dog, Height=172.5 and get the following JSON without referencing the fields by name? {"Name":"Mike","Weight":64,"Age":24,"Pet":"dog","Height":172.5}

(no quotes around numbers)