json-rpc: never crash when validating request
Instead produce the empty unit for failure cases, like the function
signature implies.
^- (unit request)
?~ body ~
?~ jon=(de-json:html q.u.body) ~
- :: ignores non-object responses
- ::
- :: ?. ?=([%o *] json) ~|([%format-not-valid json] !!)
- ?. ?=([%o *] u.jon) ~
- %- some
%. u.jon
- =, dejs:format
- :: TODO: If parsing fails, return a proper error (not 500)
- ::
+ =, dejs-soft:format
%- ot
:~ :: FIXME: parse 'id' as string, number or NULL
::
::
:- 'params'
|= =json
- ^- request-params
- ?+ -.json !!
- %a [%list ((ar same) json)]
- %o [%map ((om same) json)]
+ ^- (unit request-params)
+ ?+ -.json ~
+ %a `[%list ((ar:dejs:format same) json)]
+ %o `[%map ((om:dejs:format same) json)]
== ==
::
++ error
