How to remove comma atfer last line in json file

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
image

i have lst row number in variable which i ma fatching using System.IO.File.ReadAllLines(“Error - Formatted\P003324-384_3.json”).Length

@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

@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

checked but not worked

please check this error

@Mathkar_kunal

Try the below syntax

If (JsonString.EndsWith(","), JsonString.Substring(0, JsonString.Length - 1), jsonString)

Regards