Please enable JavaScript.
Coggle requires JavaScript to display documents.
Робота з JSON (добавить/убрать елемент, прочитать значение) (start (//pop…
Робота з JSON (добавить/убрать елемент, прочитать значение)
start
//pop into variable
decision
Choose type of pop
//multiple
I will cut from array until the end
%customVar=$.items %peoples pop()
%customVar
%peoples
#
//single
I will put some data into customVar
%customVar=$.items %peoples pop()
%customVar
%peoples
#
//set value
%var=Lolkek
We will set new value
$.type %peoples set(%var)
%peoples
#
//add element
Lets combine them!
$.items %peoples add(%element)
%peoples
#
%peoples
%customVar=null
// read value
%var=$.type %Peoples
%var
#
//remove element
Now, lets remove some element:
$.items[0] %peoples remove()
%peoples
#
//remove key
Now, lets remove some key
$.items %peoples remove()
%peoples
#
%element
%peoples={"type":"people","items":[{"name":"Viktor","age": 21},{"name":"Alex","age": 31},{"name":"Vladimir","age": 45},{"name":"Igor","age": 15}]}
%element={"name":"Sergey","age":19}