franrua02
(Francisco)
1
Hey, guys
Do you know how to get the keys from a JSON if certain condition is met?
For instance, let’s suppose I have the following JSON structure:
{"Options":{"B":true,"C":true},"submit":true}
Now if I were to retrieve B or C only if their values are true, how would I do it?
Thank you in advance!
@franrua02 Check if this is what you needed :
JsonValueExtraction.zip (1.9 KB)
2 Likes
ppr
(Peter Preuss)
3
@franrua02
we can do it in oneliners once the JSON is parsed:
getting all True Options Keys: (returns array of String {“B”,“C”})
JObject.FromObject(JObj("Options")).Properties.Where(Function (p) Convert.ToBoolean(p.Value)).Select(Function (n) n.Name.ToString).toArray
Getting a Boolean return indicating if 1 or more true options are present)
JObject.FromObject(JObj("Options")).Properties.Any(Function (p) Convert.ToBoolean(p.Value))
Find demo XAML here:
Filter_ValueAsJObject.xaml (5.4 KB)
2 Likes
franrua02
(Francisco)
4
Yes, this is it. Thank you!
system
(system)
Closed
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.