Closed sbcgua closed 1 year ago
good idea. I would allow any valid JSON value as the xyz part. no guessing or converting types. maybe setval
is better.
setval
sets
setv
set_v
set2
I wonder if there should be syntax to directly set root node ? And how should it looks like ?
e.g. if /a/b/c: 123
is a node, then 123
is directly root ? Or maybe :123
? On the one hand :
is more visible and actually means that there is the empty path, which is root. (by the way /:123
can also be an option). On the other hand such a syntax does not have any equivalents in json. While pure 123
is a valid json ...
I'm usually defining a corresponding structure and do ABAP to JSON or JSON to ABAP. Sometimes getting values directly. But I don't construct JSON via individual set statements. Still set with '/path:value' looks ok to me. To set a string I would do same method with '/path:"value"'
Yeah, it's the matter of use-cases then. I find it potentially useful for setting some constants in API structures (which happen) and also in Unit tests which are usually constructed in code with fixed values.
Anyway the code is ready (#142) welcome to review. At least the docs :))
Kind of "syntaxic sugar"
for the UTs case, abap sadly does not support multiline strings, like e.g. JS
x = `
hello
world
`
I guess this can be closed
For manual structure creation (looks quite typical for various API requests), it could be more readable to use a simplified one-line version of
set
.vs
s
stands for short or string (would like to keep the method name short){ "type_id": 12 }
set
for exceptions.set
to the rescueAny thoughts ?