I have data as follows:
String s = "foo.com^null^[]";
String s1 = "bar.com^null^[{\"seen_first\":1357882827,\"seen_last\":1357882827,\"_id\":\"93.170.52.31\",\"exclude_from_publication\":false,\"locked\":false,\"agent\":\"domain_export\",\"web_published\":true,\"version\":\"IPv4\"},{\"seen_first\":1357882827,\"seen_last\":1357882827,\"_id\":\"93.170.52.21\",\"exclude_from_publication\":false,\"locked\":false,\"agent\":\"domain_export\",\"web_published\":true,\"version\":\"IPv4\"}]";
And note that third field.. it can be either [] or a json array. And I am trying to parse these fields..
Here is my current attempt.
public static void check(String s) {
String [] tokens = s.split("^");
System.out.println(tokens[0]);
System.out.println(tokens[1]);
System.out.println(tokens[2]);
if (tokens[2].trim().equals("[]")) {
System.out.println("here--> " +true);
}
System.out.println("---------");
}
What am i doing wrong?