nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NIFI-4269) GetMongo should be able to provide pure JSON as well as "extended JSON"
Date Tue, 22 Aug 2017 23:57:01 GMT

    [ https://issues.apache.org/jira/browse/NIFI-4269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16137637#comment-16137637
] 

ASF GitHub Bot commented on NIFI-4269:
--------------------------------------

Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2063#discussion_r134629298
  
    --- Diff: nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java
---
    @@ -151,17 +172,34 @@ public ValidationResult validate(final String subject, final String
value, final
             return propertyDescriptors;
         }
     
    -    private ObjectMapper mapper = new ObjectMapper();
    +    private ObjectMapper mapper;
     
         //Turn a list of Mongo result documents into a String representation of a JSON array
    -    private String buildBatch(List<Document> documents) throws IOException {
    -        List<Map> docs = new ArrayList<>();
    -        for (Document document : documents) {
    -            String asJson = document.toJson();
    -            docs.add(mapper.readValue(asJson, Map.class));
    +    private String buildBatch(List<Document> documents, String jsonTypeSetting)
throws IOException {
    +        StringBuilder builder = new StringBuilder();
    +        for (int index = 0; index < documents.size(); index++) {
    +            Document document = documents.get(index);
    +            String asJson;
    +            if (jsonTypeSetting.equals(JSON_TYPE_NORMAL)) {
    +                asJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(document);
    --- End diff --
    
    You know, I actually think this might have not worked for me so I'm going to remove it
for now.


> GetMongo should be able to provide pure JSON as well as "extended JSON"
> -----------------------------------------------------------------------
>
>                 Key: NIFI-4269
>                 URL: https://issues.apache.org/jira/browse/NIFI-4269
>             Project: Apache NiFi
>          Issue Type: Improvement
>            Reporter: Mike Thomsen
>
> GetMongo currently only supports "extended JSON." That results in ugly JSON like this:
> {
>     "timestamp": {
>         "$date": LONG_TIMESTAMP
>     }
> }
> instead of something cleaner like this:
> {
>     "timestamp": "2017-08-07T00:00:00Z"
> }
> GetMongo should be refactored to support both modes of JSON serialization.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message