Hello,
I am writing json in text file and it is ending with comma.
i ned to remove that lsat comma, how can i reov ethat
check below image.
i need like below
i have lst row number in variable which i ma fatching using System.IO.File.ReadAllLines(“Error - Formatted\P003324-384_3.json”).Length
rlgandu
(Rajyalakshmi Gandu)
August 4, 2023, 6:49am
3
@Mathkar_kunal
Read the JSON Text from the File:
Use the “Read Text File” activity to read the contents of the JSON text file into a string variable.
// Assuming the JSON text is stored in a variable called jsonText
if (jsonText.EndsWith(“,”))
{
jsonText = jsonText.Substring(0, jsonText.Length - 1);
}
Use write Text file
vrdabberu
(Varunraj Dabberu)
August 4, 2023, 6:50am
4
@Mathkar_kunal
Read Text File (File: “path/to/your/file.json”)
Output: jsonString
Assign
To: jsonString
Value: If jsonString.EndsWith(“,”), jsonString.Substring(0, jsonString.Length - 1), jsonString
Write Text File (File: “path/to/your/file.json”, Text: jsonString)
Regards
vrdabberu
(Varunraj Dabberu)
August 4, 2023, 8:39am
7
@Mathkar_kunal
Try the below syntax
If (JsonString.EndsWith(","), JsonString.Substring(0, JsonString.Length - 1), jsonString)
Regards