Replace JSON value

92 views
Skip to first unread message

Shamil

unread,
May 17, 2023, 10:11:01 AM5/17/23
to Automate
hiya! I've been scrambling to fix this problem for a few hours and I can't seem to do it. 
So the issue is that I want to replace a json value that I've collected from a http request and save it as a json variable 

To visualise: 
the http request value: { status: "success", data: { item: "red" }}
I wanna get the data and replace red to green and just save the data object

Thank you!!

Henrik "The Developer" Lindqvist

unread,
May 17, 2023, 10:51:00 AM5/17/23
to Automate
To get the data:
  1. Variable set: json = jsonDecode(httpResponse)
  2. Log append: Message= json["data"]
To replace the data:
  1. Variable set: json = jsonDecode(httpResponse)
  2. Dictionary put: Variable=json, Key=data, Value={ "item":"green" }

Shamil

unread,
May 17, 2023, 11:37:04 AM5/17/23
to Automate
Is it possible to leave the other items in the data object in the json variable 

Henrik "The Developer" Lindqvist

unread,
May 17, 2023, 11:58:22 AM5/17/23
to Automate
The you need to assign it a variable first:
    1. Variable set: json = jsonDecode(httpResponse)
    1. Variable set: data= json["data"]
    2. Dictionary put: Variable=data, Key=item, Value="green"
    Reply all
    Reply to author
    Forward
    0 new messages