Created 02-28-2018 09:03 AM
Hello community,
We are experiencing an invalid scenario in our implementation.
After receiving an input JSON with integer values from ListenHTTP processor, the values are sent to a Kafka processor which uses JsonTreeReader 1.4.0 as record reader and JsonRecordSetWriter 1.4.0 as record writer.
After this processing, integer values from JSON are converted to String.
Is this the correct behavior?
Is there a way to keep the original format?
input:
{
"sample": 123
}
output:
{
"sample": "123"
}
Thanks,
Tiago
Created 02-28-2018 01:37 PM
Can you share your input/output schemas? My guess is that in the schema, the data type is specified as "string" rather than "int".
Created 03-01-2018 03:01 PM
Sure, schema is something similar to:
"fields": [ { "name": "sample", "type": "string"}]
I understand now that the type of field will define the output type of our writer.
A new question came out, is it possible to have the record invalidated since the sample came as 123 int instead of "123" string?
We would like to avoid the type coercion provided by JsonTreeReader:
Created 03-05-2018 03:36 PM
You should be able to use ValidateRecord using the original schema, if types are coerced by a reader/writer (which I think might be a bug if they do), then they should fail validation (assuming the same bug/behavior is not in both places).