Removing null

As I use document understanding to extract the data from pdf and convert into json.
When using the Document understanding process the empty field value are marked as “null” in the output json. But Instead of null I need to put “” double quotes in it.

Try to use Replace function

it’s not working

use System.Text.RegularExpressions.Regex.Replace(text, " “,” ")

Do you need it to not be null because its causing errors down the line (such as an assign not accepting a null)?

If so, I would recommending passing it as an argument to a custom class.

This way you can consolidate all the if null, then blah type work without doing 1000 assigns later on.

Hi @agathiyanv ,

Could you let us know How you are exporting the extracted data into json file ?

If possible, we could try manipulating the data before hand and then export the data into Json, Or most probably we should be able to convert the extracted data into datatable and we can update the values accordingly as needed.

Let us know what is the purpose of using Json format and the method you have used to convert to Json file.

Hi when you extract a pdf into JSON, it will result in key value pairs. Here you cannot simply replace “null” with " " that would result in the JSON file erroring out.

You can change “null” to “-” with a simple replace text but you cannot replace into " ".

if you want to remove “null” values, you will have to remove the entire key values from the JSON file.

Here’s an example of text showing “null”

now you can replace “null” to “-” with system.text.regularexpressions.regex.replace(“null”,“-”) if that works for you but if you want to remove “null” to " " you will have to remove this entire section.

you can do it by creating a dynamic regex replacement. try

I used it to remove similar null values in json. let me know if you need any help on this.