I have two Strings and a Json response :
- InputString = "ab";
- OutputString = "";
- Json(example, not real one): Array(From:a,to:bhduh - From:b, to:eiaja).
*Json isn't a real response, it has 2 records for this example .
What i want to do is to replace a with bhduh and b with eiaja, I have a JSON loop which tell me to what i should replace, and i need to do it inside that loop, So here's what i tried :
InputString = InputString.replace(From,To);
Output
eiajahduheiaja
Expected Output
bhduheiaja
This's happening because in the first loop, it's changing a, and in the second loop, there's two b, the b in bhduh and b in the normal String.
The loop times depend on letters count, so sometimes it can be 5 or 6, depending on the server Json response.
What i want is to have the Expected Output, any ideas ?