title: Spring MVC, JSON, wrong serialization of string fields, that are longer than 1000 characters
body: <p>I try to send list of entities as JSON data from server to client via annotation @ResponseBody. Problem is that text fields, longer than 1000 serialize incorrectly. In this case string replase on null symbols "\u0000" sequence.</p>
  
  <p>I configure JSON mapper:</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @EnableScheduling
  @ComponentScan({"configs", "controllers", "services", "models"})
  public class WebConfig
  {
      @Bean RequestMappingHandlerAdapter requestMappingHandlerAdapter()
      {
          RequestMappingHandlerAdapter reqMapHAdapter=new RequestMappingHandlerAdapter();
  
          Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
          builder.indentOutput(true);
          MappingJackson2HttpMessageConverter httpMsgConv=new MappingJackson2HttpMessageConverter(builder.build());
          httpMsgConv.setPrettyPrint(true);
  
          ArrayList&lt;MediaType&gt; mediaTypes=new ArrayList&lt;&gt;();
          mediaTypes.add(new MediaType("application", "json", StandardCharsets.UTF_8));
          httpMsgConv.setSupportedMediaTypes(mediaTypes);
  
          ArrayList&lt;HttpMessageConverter&lt;?&gt;&gt; msgConvs=new ArrayList&lt;&gt;();
          msgConvs.add(httpMsgConv);
  
          reqMapHAdapter.setMessageConverters(msgConvs);
          return reqMapHAdapter;
      }
      ...
  }
  </code></pre>
  
  <p>Controller's method:</p>
  
  <pre><code>@Controller
  public class MyController
  {
      @RequestMapping(value={GET_MESSAGES_URL}, method=RequestMethod.GET)
      @ResponseBody List&lt;MessageViewItem&gt; getMessages()
      {
          // getting List&lt;MesssageViewItem&gt;
          List&lt;MessageViewItem&gt; messages=...;
          return messages;
      }
  }
  </code></pre>
  
  <p>MessageViewItem class:</p>
  
  <pre><code>public class MessageViewItem 
  {
      private String  text,
                      localizedSendingDate;
  
      private UserShortViewItem author;
  
      private Long  messageId;
  
      // default constructor, getters and setters ...
  }
  </code></pre>
  
  <p>And results, if text.length()&lt;=1000:</p>
  
  <pre><code>[ {
    "text" : "123",
    "localizedSendingDate" : "1 day ago",
    "author" : {
      "viewName" : "John Doe",
      "imageUrl" : "/test_web_spring/images/usersImages/0/0/4.jpg",
      "id" : 940
    },
    "messageId" : 3540
  } ]
  </code></pre>
  
  <p>If text.length()>1000 ( I cut large part "\u0000" from message ):</p>
  
  <pre><code>[ {
    "text" : " : \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
  \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
    "localizedSendingDate" : "3 hour ago",
    "author" : {
      "viewName" : "John Doe",
      "imageUrl" : "/test_web_spring/images/usersImages/0/0/4.jpg",
      "id" : 940
    },
    "messageId" : 3812
  } ]
  </code></pre>
  
  <p>Altough, manually call ObjectMapper.writeValueAsString work as expected and serialize text field longer than 1000 characters normally.</p>
  
  <p>Any ideas, how to fix this issue?</p>
  
  <p>ADD: Test controller's method: </p>
  
  <pre><code>@RequestMapping(value={"/testJsonConv"}, method=RequestMethod.GET)
  @ResponseBody MessageViewItem testJsonConv()
  {
      MessageViewItem msgViewItem=new MessageViewItem();
      msgViewItem.setText("Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo");      
      return msgViewItem;
  }
  </code></pre>
  
  <p>result(cut large part "\u0000"):</p>
  
  <pre><code>{
    "text" : " : \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
    "localizedSendingDate" : null,
    "author" : null,
    "messageId" : null
  }
  </code></pre>