How to convert xml to json

Hi all,

How to convert xml to json format. I cant use market packages is there any .net code available?

May we ask you to share some sample data (nput ixml, expected output json) with us?

@ppr sorry for that i can’t share the results it’s an confidential data

no problem, as you can share samples with redacted or anonymized data from which we can get the structures as well

Hi,

If your xml is simple structure, the following might help you.

strJson = JsonConvert.SerializeXNode(xdoc, Newtonsoft.Json.Formatting.Indented)

Regards,

strjson is of string type?
and I am geeting error
Message Box: An error occurred trying to start process ‘C:\Users\ajindal.nuget\packages\UiPath.system.activities\22.10.4\build\net461\WorkerProcess.exe’ with working directory ‘C:\Users\ajindal\Documents\E2e_rgc\End to End’. The filename or extension is too long.

Hi,

For now, can you try to use WriteTextFile activity instead of MessageBox becuase the result might be too long.

Regards,

Thanks for the help
It is working for now I am checking for the multiple files.

@Yoichi
I am getting this error,
error BC30652: Reference required to assembly ‘System.Xml.XDocument, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ containing the type ‘XObject’. Add one to your project. XML Comparison.xaml.
I tried installing System.Xml.XDocument, but it was not getting installed.
Shows below error:
Package Installation Failure
image

Hi,

What is XObject?

Regards,

Are you importing any packages while using this function?
strJson = JsonConvert.SerializeXNode(xdoc, Newtonsoft.Json.Formatting.Indented)

HI,

Can you try to install UiPath.WebAPI.Activities package?

Regards,

1 Like