Hi CB Team,
While using RAW META() clause, to fetch list of order id , the N1qlQueryResult retives the ArrayResult with in the String / wrapped with String , do you know how we can put into ArrayList.
Hi Mehul,
Looks like you’ve got a JSON array. You could parse it using com.couchbase.client.java.document.json.JsonArray, like this:
String jsonString = "[\"019999310850\", \"02970340053\", \"0397056733\", \"04908626533\"];
JsonArray jsonArray = JsonArray.fromJson(jsonString);
for (int i = 0; i < jsonArray.size(); i++) {
System.out.println(jsonArray.getString(i));
}
Alternatively, you could use Jackson for parsing:
ObjectMapper mapper = new ObjectMapper(); // can be static final
List<String> list = mapper.readValue(jsonString,
new TypeReference<List<String>>(){});
System.out.println(list);