44
55The simplest script in JSONScript is a single instruction that calls an external executor method with some arguments:
66
7- ``` JSON
7+ ``` json
88{
99 "$exec" : " router" ,
1010 "$method" : " get" ,
@@ -40,7 +40,7 @@ An asynchronous value is a value that is currently not available and will be ava
4040
4141JSONScript can include several instructions that will be executed sequentially:
4242
43- ``` JSON
43+ ``` json
4444[
4545 {
4646 "$exec" : " router" ,
@@ -65,7 +65,7 @@ Sequential evaluation is not limited to executing individual instructions - any
6565
6666For example, this script does the same as the script above for two resources:
6767
68- ``` JSON
68+ ``` json
6969[
7070 [
7171 {
@@ -101,7 +101,7 @@ The result of this script evaluation is the array of two arrays containing two i
101101
102102JSONScript can include several instructions that will be executed in parallel:
103103
104- ``` JSON
104+ ``` json
105105{
106106 "res1" : {
107107 "$exec" : " router" ,
@@ -126,7 +126,7 @@ Parallel evaluation is not limited to executing individual instructions - any sc
126126
127127For example, the script below is similar to the example in the previous section that updates two resources but it does it in parallel:
128128
129- ``` JSON
129+ ``` json
130130{
131131 "res1" : [
132132 {
@@ -168,7 +168,7 @@ Let's see what other instructions are defined in JSONScript core.
168168
169169During the evaluation the script can use the data instance passed to the interpeter in addition to the script:
170170
171- ``` JSON
171+ ``` json
172172[
173173 {
174174 "$exec" : " router" ,
@@ -185,7 +185,7 @@ During the evaluation the script can use the data instance passed to the interpe
185185
186186Data instance:
187187
188- ``` JSON
188+ ``` json
189189{
190190 "path" : " /resource/1" ,
191191 "body" : { "test" : " test" }
@@ -200,7 +200,7 @@ Not only some part of arguments can use scripts to evaluate it, any value in the
200200
201201For example, the executor name can be the result of the call to another executor:
202202
203- ``` JSON
203+ ``` json
204204{
205205 "$exec" : { "$exec" : " chooseRouter" },
206206 "$method" : " get" ,
@@ -215,7 +215,7 @@ The script can use results from any part of the script in another part of the sc
215215
216216The previous example where executor name was the result of another script evaluation could be re-written like this:
217217
218- ``` JSON
218+ ``` json
219219{
220220 "router" : { "$exec" : " chooseRouter" },
221221 "response" : {
@@ -248,7 +248,7 @@ JSONScript interpreters should both try to determine such situations as early as
248248
249249` $if ` instruction can be used to choose the strict that will be evaluated based on some condition:
250250
251- ``` JSON
251+ ``` json
252252{
253253 "$if" : { "$exec" : " checkAvailability" , "$args" : " router1" },
254254 "$then" : {
@@ -274,7 +274,7 @@ Please note that the interpreter should NOT evaluate both scripts and choose the
274274
275275Scalar values can be used in any place where the script is expected - they evaluate to themselves. We can refactor the script above in this way:
276276
277- ``` JSON
277+ ``` json
278278{
279279 "$exec" : {
280280 "$if" : { "$exec" : " checkAvailability" , "$args" : " router1" },
@@ -288,7 +288,7 @@ Scalar values can be used in any place where the script is expected - they evalu
288288
289289or using reference:
290290
291- ``` JSON
291+ ``` json
292292{
293293 "router" : {
294294 "$if" : { "$exec" : " checkAvailability" , "$args" : " router1" },
@@ -310,7 +310,7 @@ or using reference:
310310
311311` $delay ` instruction can be used to delay the start of evaluation of any script. That can be useful, for example, if you need to ensure that one script starts evaluating after another script starts, but you don't need for it to wait for the completion (as in sequential processing):
312312
313- ``` JSON
313+ ``` json
314314{
315315 "res1" : {
316316 "$exec" : " router" ,
@@ -332,7 +332,7 @@ The evaluation result will be the same as without `$delay` istruction, but the s
332332
333333This instruction can also be used to create asynchronous value from synchronous value. For example if some executor expects an asynchronous value as an argument and you want to pass a constant, you can use ` $delay ` :
334334
335- ``` JSON
335+ ``` json
336336{
337337 "$exec" : " logger" ,
338338 "$method" : " resolve" ,
0 commit comments