I have an HTTPResonse that when you get the body looks like this:
{"id":"/Project/34rxq38ntgrvxj7vkzqj8xe7v68"}
I want to get the Id from it to use later and I'm having trouble figuring out how to dynamically say start at Project/ and end at "}. The reason is that the id seems to change in length each time.
I did have
String i = response.getBody().subString(16,45);
but it fails if the length changes. I think I should do something like this to get the index of the last " and then use that as the length but I can't get it to compile.
String i = response.getBody().substring(16, indexofChar('"',16));
The error is:
Method does not exist or incorrect signature: void indexofChar(String, Integer)
What am I doing wrong?
String i = response.getBody().substring(16, response.getBody().indexofChar('"',16));
Again, Derek's answer is a much better approach for the given use case.