Reputation: 13
How to split json data in PowerApps
I have a json format text {"ID":"1","name":"yashpal"} and I need to split the data and assign 1 to textbox1 and Yashpal to textbox2
Upvotes: 1
Views: 534
Reputation: 87308
Power Apps currently does not have a general JSON parsing mechanism, but if you know that the text you have will always have the same format, and the 'name' property cannot have double quotes ("
), then you can use a regular expression to extract the values, something along the lines of
With(
Match(
<<the json text>>,
"\""ID\"":\""(?<id>[^\""]+)\"",\""name\"":\""(?<name>[^\""]+)\"""),
UpdateContext({defaultId: id, defaultName: name}))
And you can use the variables defaultId
and defaultName
as the Default property of 'textbox1' and 'textbox2', respectively.
Upvotes: 1