I have a web service that uses Scott's port of YAJL to parse a request into about 100 fields. About half of those fields are numeric. If one of the numeric fields overflows the field size defined in the data structure fed to YAJLINTO, the parser returns an "Invalid JSON data" message, with no further information about which fields are invalid. The consumers would of course find it very helpful to know which field has invalid data. Currently, the only solution I have is to use huge sizes for all of the numeric fields and do all my own overflow checks after parsing. Is there a way to get YAJLINTO to provide field-level error info? Thanks!
Announcement
Collapse
No announcement yet.
Numeric field error reporting in YAJLINTO
Collapse
X
-
Well, you can turn on the DATA-INTO trace and see where it stops. Though, RPG normally tells you which field it failed on, so there's that, too.
YAJLINTO can't tell you when a field is too big -- it has no way of knowing how the fields are defined or whether a value will overflow them. The DATA-INTO opcode handles that part... It could keep a lof of what JSON fields it is processing... but the existing DATA-INTO trace already does that, so not sure what good that would do.
-
Looking at the statement above that RPG tells you which field it failed on... maybe I'm missing information that's already there? I just realized the "Invalid JSON data" message doesn't come from DATA-INTO, it's from my code:
Code:monitor; data-into req %data('*STDIN' : 'case=convert countprefix=num_ allowextra=yes allowmissing=yes') %parser('YAJLINTO'); on-error; addHdrErr('Invalid JSON data'); return; endmon;
Comment
Comment