Googleアナリティクス

2018年2月5日月曜日

Rewrite child element value using setPropety Function.

Original post is here.

It is a setProperty function for manipulating the value of a JSON object in LogicFlow, but if you wanted to rewrite a child element, it took a bit of effort to do it.

I tried to do as follows.

It is a JSON value having elements "aaa" and "bbb", and "ccc" and "ddd" exist as child elements for "bbb". If we wanted to rewrite the value of ccc at this time, we can not simply use setProperty function.

image

I will create LogicFlow like below, for verify it.

image

Create the object variable "wkJson", set original JSON value.

Next, rewrite the value of ccc using setProperty function.

By using setProperty function like this below, we could rewrite ccc value.

setProperty(variables('wkJson'),'bbb',setProperty(variables('wkJson')?.bbb,'ccc','100'))

This is a way to use two setProperty functions.It is the part of "setProperty (variables ('wkJson') ?. bbb, 'ccc', '100')" described in, but for the value of bbb of the variable wkJson, the child element ccc of bbb is set to 100 .

As a result, we rewrite bbb of variable wkJson. The setProperty function returns the result with the rewritten result as another variable and does not really rewrite the variable specified by the rewriting. In terms of LogicFlow above, we finally check the value of wkJson at "作成2", but here we have the same value as when we first created the variable.

image

In this way, when rewriting only the result and child elements, you can edit JSON values as you like by carefully using nested setProperty function.

0 件のコメント:

コメントを投稿