I need help formatting json in a text file. The content of the file is like this:
I want to format it by removing the variable name “id” and the double quotes. So it should look like the below after formatting it:
‘12-22-22-22-22’, ‘22-33-3-66-67’, ‘45-66-43b6-77-88’, ‘66-3d8f-tt-77-77’, ‘66-3-3-44-44’
I tried to deserialize the json, but it seem I’m missing something. Attached is my work flow.
formatJson.zip (2.5 KB)
arrLines | String Array =
File.ReadAllLines(strPath) | strPath is Full FilePath to the text file
arrValues | String Array =
arrLines.Select(Function (x) Newtonsoft.Json.Linq.JObject.Parse(x)(“id”).Value(Of String)).ToArray()
then use in write Test File for the content:
we did not surround the values with a ’ (can addapt it)
Do you use the File.ReadAllLines(strPath) inside the assign activity? U’m getting errors. Could you kindly upload the workflow where you captured the screenshot from? Thanks
Just configure the variable strArry to String Array
then select string
The Text file is not a proper JArray
Was done within the immediate panel
Thanks, I resolved that issues and I got this.
I actually saved my change before running, not sure where the compile error is coming from
ensure the the double quote is of
" and not the inverted one
@ppr That fixed the issue, but how can format it to have that single quote them.
They must be formatted like this:
We recommend that you reread the answers and also check the given screenshots
here you can also adapt the needed surrounding character
This is my code:
String.Join(“,”,strArry.Select(Function(x)“'” & x & “'”))
and it errored, Am I doing something wrong?
and it errored,
When sharing error details with us, we can faster help
Also you can direclty prototype within immediate panel by yourself:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum
ensure that the correct
' is used
Sorry I didnt share the error detail earlier. It seems it has to do with the " usage but I’m not too sure. Below is excatly how I had it in the expression editor:
String.Join(“,”,strArry.Select(Function(x)“'” & x & “'” ))
Unfortunately we a running in a longer ping-pong communication, things were cleared much early.
Delete the statement and retype it carefully again
Ensure the correct
ensure also the correct usage of variables
We cannot see the reason why immediate panel is not used. But when the issue is again occuring then at least debug and check which of the two write text file is failing
@ppr Retyping solved the issue! Thanks
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.