I parse JSON, and even If JSON is invalid I want to save it.
So I created an additional variable "invalid". If there is an exception, the method should return "saved" invalid var, but it doesn't -
def jsonParse(str, ev)
invalid = str
begin
parsed = JSON.parse(str)
rescue => e
ev.tag("_parseJsonFail")
return invalid
end
return parsed
end
I have created for additional "debug level" this method:
def jsonParse(str, ev)
invalid = str
if invalid then
ev.set("X1",invalid)
else
ev.set("X2-invalid",invalid)
end
begin
parsed = JSON.parse(str)
rescue => e
ev.tag("_parseJsonFail")
ev.set("X3",parsed)
ev.set("X4",invalid)
return invalid
end
return parsed
end
@Badger Thanks a lot you were right!!
When i pass to logs: {"aaa":"123"}
It breaks
So it should be passed (with spaces): {"aaa" : "123"}
magic! Need some time to solve it
Anyway, shake your hand! Thanks for your help!
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.