I have two Strings, one is a JSON string( that is i created a json obj and converted it to string using obj.tostring() and passed it to another class) and an ordinary string with characters no words or meaning like "abcdefg".
This below is the json format string s1:
{"email_prompted":"n","error":"o","pin":"c","antiphishing_prompted":"n","antiphishing":"n"}
The other string is s2: "EoPnAn"
In String s2 the characters E represents error P represents pin and A represents antiphishing.
Now i want to compare the value of error in s1 "o" is equal to the second character in s2. that is i want to check the values of error, pin and antiphishing with second, fourth and sixth characters of s2.
And if all three are equal i want to print "ok".
I am not asking for u to write me a code but give me a hint on how to do it. But if u provide a code or example it is much appreciated.
The following is an over simplification of what i wanted. Sorry for my overly simple code but will this work?
String s1="{"email_prompted":"n","error":"o","pin":"c","antiphishing_prompted":"n","antiphishing":"n"}" ;
String s2="EoPnAn";
char[] p1 = s1.toCharArray();
char[] p2 = s2.toCharArray();
if(p1[31]==p2[1] && p1[41]==p2[3]&&p1[88]==p2[5]){
System.out.println("OK");
}