Updates to working with JSON in Power Apps

Recently Microsoft made some updates to how we can work with JSON in Power Apps to make things simpler for makers and more similar to working with simple data sources. In this blog post I’ll share a couple of my favourite enhancements making working… READ MORE [https://lewisdoes.dev/blog/updates
a person holding a paper
Photo by RealToughCandy.com on Pexels.com
In: Low Code Lewis Content 🚀

Recently Microsoft made some updates to how we can work with JSON in Power Apps to make things simpler for makers and more similar to working with simple data sources. In this blog post I’ll share a couple of my favourite enhancements making working with JSON easier in Power Apps.

Automatic conversion of untyped data type

One of the enhancements made by Microsoft allows us to now specify a formula using an untyped objects property without having to convert the data type.

In the same way that we can use a number value in the ‘Text’ property of a text label, and Power Apps will display the converted number as a string, we can now reference untyped values and Power Apps will automatically make a conversion if it can find a suitable data type to convert to!

So… we used to have to reference text values like this…

Text(ThisItem.Value.strDrink)

This is an example of me referencing a field in an untyped object which is within a table held in a variable. This is from my cocktails app series, which you can read more on below…

But now, we can reference fields without the data type conversion and Power Apps will try to make a suitable conversion for us!

So I can now reference fields like this again…

ThisItem.Value.strDrink

This might only be a small gain back of time when working with simple examples like this, but when writing bigger formulas this is super helpful!

Easier to make conversions

The next enhancement Microsoft has made is around conversions. Say for example I have a number field I want to reference which looks like this in JSON … { number: “1” }. In my JSON this is actually a string data type because of the double quotes around my number.

In Power Apps this would mean I can’t use Value() straight away as my conversion. My first conversion would always have to match to the actual underlying data type to the untyped value. Then you’d be able to make the second conversion around that first one.

So what used to be this…

Value(Text(untypedObject.number))

Can now just be this…

Value(untypedObject.number)

SO much easier!

Using functions without conversion

Similar to how you now don’t have to convert to the matching data type to then make the conversion you want to, you now don’t have to make the matching data type conversion prior to using other functions with an untyped objects property value.

For example, below I’ve used a concatenate function in a text label to concatenate multiple strings which are actually seen by Power Apps as untyped. But now, Power Apps is making the conversion automatically for me and all I need to do is work with the function I want to.

Working with operators and untyped objects

Again, in the same way as I have directly used functions with untyped object values above, I can also use operators with them. For example, if I have a JSON string which has a number value in it, I can use a formula such as the one below without needing to make data conversions.

untypedObject.number * 100 

Moving into preview soon

Microsoft have also now reported that they are happier with the set of features that are available around ParseJSON() in Power Apps and when working with untyped objects. It’s been reported this month that these features will soon be moving out of the experimental state!

Overview

So the main message is that you no longer need to make data conversions to untyped object values to work with your own wanted conversions, operations, functions, or when you simply just want to reference a field in an untyped object!

Written by
Lewis Baybutt
Microsoft Business Applications MVP • Power Platform Consultant • Blogger • Community Contributor • #CommunityRocks • #SharingIsCaring
Comments
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to LewisDoesDev.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.