Extracting a string from JSON input


I have the below JSON input file and I need to loop through each item and extract only the reference number before the slash, e.g. “235791”.


However, every now and then I get this error in Orchestrator:

"Execution error : System.ArgumentOutOfRangeException: Length cannot be less than zero.\r\n at System.String.Substring(Int32 startIndex, Int32 length)…

strLongInstruction = item.ToString.Substring(item.ToString.IndexOf(":"),item.ToString.IndexOf(",") - item.ToString.IndexOf(":") +1).Replace(": “,”").Replace("""","").Replace(",","")

strInstruction = strLongInstruction.ToString.Substring(0, strLongInstruction.ToString.IndexOf("/"))

strSI = strInstruction.Concat(strInstruction.Where(AddressOf Char.IsDigit))

strInstructionExtn = strLongInstruction.ToString.Substring(strLongInstruction.ToString.LastIndexOf("/") + 1)

I am not really a programmer so I only pieced together what I was able to find online in terms of string manipulation. Please see attached the files.

Many thanks!

Rather than using string manipulation, I’ll suggest use Regex


Just try this , I’m getting the exact required values for the JSON you provided above :slight_smile:

newJson.xaml (5.4 KB)

Wow simply awesome! Thanks very much @HareeshMR

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.