I have an output string in console in which this code appears several times with a different value. I would like to get dinamically the value without the n_id.
All those suggestions would use a regex for what you want to get rid of, or for what you want to keep. If you are certain that the length of the prefix you want to get rid of is always the same, try String#substring().
That looks like JSON, so the obvious approach would be to use one of the many available JSON libraries. https://github.com/stleary/JSON-java would be a good choice.
Edit: I added linebreaks to the JSON so that the page is formatted properly, and also took the liberty of removing much of the duplicated data.
Isaac Ferguson wrote:I think that as it is a json result fro a rest call, I should convert it into a array...
What you have posted appears to be part of a larger JSON document, which looks mal-formed. Right at the beginning, the [ character indicates an array is following, but then there rather than array values, there are key-value pairs, which would normally be part of an JSON object.
Can you post a smaller and complete one to look at?
Changing the beginning array to an object, your data would look like this:
Isaac Ferguson wrote:I get the error when using reader.beginArray();
You didn't include the complete stack trace, but I bet that this exception was at line 11:
String value = reader.nextString(); not line 8:
reader.beginArray();
Isaac Ferguson wrote:Any idea, please?
After entering the array, you are trying to read a string, but the next value found was an object.
Looking at your document, it has a [ token which indicates the start of an array, followed by a { token which indicates the start of an object. There is no string.