java - Finding a way to parse multi-type JSON field -


we have json-answer server, have array of byte arrays, there can "none" string value instead of empty array. example:

{'jsonrpc': '2.0', 'id': 31, 'result': {"bytes_arrays": [[21,99,165,243,25,210,14,121,120,39,22,102,59],[22,32,42,54,65,65,76,87],none]} 

in class write this:

@jsonproperty("bytes_arrays")     private list<byte[]> marrayslist = new arraylist<>(); 

but of course, we'll have parsing error last element "none" value, because it's string.

are there ways extract multi-type field in json? use jackson.

there missing bracket @ end of json string. fixed , formatted looks this:

{     'jsonrpc' : '2.0',     'id' : 31,     'result' : {         "bytes_arrays" : [                             [ 21, 99, 165, 243, 25, 210, 14, 121, 120, 39, 22, 102, 59 ],                             [ 22, 32, 42, 54, 65, 65, 76, 87 ],                             none                           ]     } } 

jackson should able parse map<string, object>.

you can check type of object instanceof , put logic.


Comments