Closed shayanhabibi closed 3 years ago
here are some thoughts.
jsony
is loose so it does not validate the input json string is valid or not, you may get corrupt json data.
Here I don't use stringstreams
I wish I find a lib that accept parse from network io buffer.
Am not sure provide a api "Parse JSON string to Object directly" , is it necessary ? End developer can convert from JsonNode by calling one proc.
I suppose depends on needs; I am using this as my Scorper will be deployed in an internal environment where I need rapid serialisation and deserialisation. The conversion of string to JsonNodes before converting then to Objects is a sacrifice I can't make in this enterprise. Because I am assured the json is valid since I am developing the client ui which is interacting with the scorper it is a very useful api for myself. Perhaps offering it as an unsafe api?
I will require it in my own project however will keep it in my own fork for the future.
I think we can expose an API wraps exists json api , handle json parse logic in same place. the main concerns here is I want response error automatically when json data is not valid.
well , If you still need implement your own json handler , I think you can use scorper .stream
api which returns a stream reader, you can use it in your own json handler or obj handler.
I've used jsony to directly parse the string to an object since treeform mentions that the stringstreams are actually slower for this use anyway; is this indeed an efficient method?
Sorry my commit diff is horrible due to my editor settings, the link goes directly to the proc I added to your source code.
Else see here: