Updated extractJsonResult method (#2639)
* added updated example codes * updated example code StringToCharStream * deleted StringToCharStream.java locally * removed redundant file * added code for apache commons collection SetUtils * refactored example code * added example code for bytebuddy * added example code for PCollections * update pom * refactored tests for PCollections * spring security xml config * spring security xml config * remove redundant comment * example code for apache-shiro * updated example code for Vavr Collections * updated Vavr's Collection example * updated Vavr Collection file * updated example code for Apache Shiro * updated Vavr Collections example * added example code for N1QL * update example code for N1QL * added integration test for N1QL * update N1QL Example code * update the N1QL example Code
This commit is contained in:
parent
f7ab9fa910
commit
562b9fc2fe
@ -3,22 +3,27 @@ package com.baeldung.couchbase.n1ql;
|
|||||||
import com.couchbase.client.java.query.N1qlQueryResult;
|
import com.couchbase.client.java.query.N1qlQueryResult;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CodeSnippets {
|
public class CodeSnippets {
|
||||||
|
|
||||||
private static ObjectMapper objectMapper = new ObjectMapper();
|
private static ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(CodeSnippets.class.getName());
|
||||||
|
|
||||||
public static List<JsonNode> extractJsonResult(N1qlQueryResult result) {
|
public static List<JsonNode> extractJsonResult(N1qlQueryResult result) {
|
||||||
return result.allRows().stream()
|
return result.allRows().stream()
|
||||||
.map(row -> {
|
.map(row -> {
|
||||||
try {
|
try {
|
||||||
return objectMapper.readTree(row.value().toString());
|
return objectMapper.readTree(row.value().toString());
|
||||||
}catch (IOException e) {
|
}catch (IOException e) {
|
||||||
e.printStackTrace();
|
logger.log(Level.WARNING, e.getLocalizedMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user