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

ASF GitHub Bot commented on APEXMALHAR-2157:
--------------------------------------------

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

    https://github.com/apache/apex-malhar/pull/348#discussion_r71554968
  
    --- Diff: 
library/src/main/java/com/datatorrent/lib/formatter/JsonFormatter.java ---
    @@ -45,58 +38,30 @@
     @org.apache.hadoop.classification.InterfaceStability.Evolving
     public class JsonFormatter extends Formatter<String>
     {
    +  private transient ObjectMapper objMapper;
       private transient ObjectWriter writer;
    -  protected String dateFormat;
     
    +  @SuppressWarnings("deprecation")
       @Override
       public void setup(OperatorContext context)
       {
    -    try {
    -      ObjectMapper mapper = new ObjectMapper();
    -      if (dateFormat != null) {
    -        mapper.setDateFormat(new SimpleDateFormat(dateFormat));
    -      }
    -      writer = mapper.writerWithType(clazz);
    -      mapper.configure(SerializationConfig.Feature.AUTO_DETECT_FIELDS, 
true);
    -      mapper.configure(SerializationConfig.Feature.AUTO_DETECT_GETTERS, 
true);
    -      mapper.configure(SerializationConfig.Feature.AUTO_DETECT_IS_GETTERS, 
true);
    -    } catch (Throwable e) {
    -      throw new RuntimeException("Unable find provided class");
    -    }
    +    objMapper = new ObjectMapper();
    +    writer = objMapper.writerWithType(clazz);
       }
     
       @Override
       public String convert(Object tuple)
       {
    +    if (tuple == null) {
    +      return null;
    +    }
         try {
           return writer.writeValueAsString(tuple);
    -    } catch (JsonGenerationException | JsonMappingException e) {
    -      logger.debug("Error while converting tuple {} 
{}",tuple,e.getMessage());
    -    } catch (IOException e) {
    -      DTThrowable.rethrow(e);
    +    } catch (JsonProcessingException e) {
    +      logger.error("Error while converting tuple {} {}", tuple, 
e.getMessage());
         }
    --- End diff --
    
    Same as above e instead of e.getMessage()


> Improvements in JSON Formatter
> ------------------------------
>
>                 Key: APEXMALHAR-2157
>                 URL: https://issues.apache.org/jira/browse/APEXMALHAR-2157
>             Project: Apache Apex Malhar
>          Issue Type: Improvement
>            Reporter: shubham pathak
>            Assignee: shubham pathak
>            Priority: Minor
>
> We need following features in existing JSON Formatter
> 1. Ability to provide date format for different date fields in POJO. Current 
> implementation accepts just one format and applies the same to all date 
> fields.
> 2. Ability to provide JSON field to POJO field mapping.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to