'JAVA' 카테고리의 다른 글
java.lang.reflect.Method 샘플 (0) | 2013.12.05 |
---|---|
Annotation Example (0) | 2013.12.05 |
날짜 형식에서 .0 빼기 (0) | 2013.10.16 |
스트링 비교 (0) | 2013.09.26 |
[JAVA] 공부 ,유용한 사이트 (0) | 2013.07.19 |
java.lang.reflect.Method 샘플 (0) | 2013.12.05 |
---|---|
Annotation Example (0) | 2013.12.05 |
날짜 형식에서 .0 빼기 (0) | 2013.10.16 |
스트링 비교 (0) | 2013.09.26 |
[JAVA] 공부 ,유용한 사이트 (0) | 2013.07.19 |
출처 - http://www.mkyong.com/java/how-to-enable-pretty-print-json-output-jackson/
It’s easy to enable pretty print JSON output in Jackson framework. Take last object to/from json example :
User user = new User(); ObjectMapper mapper = new ObjectMapper(); System.out.println(mapper.writeValueAsString(user));
It will display JSON in compact mode :
{"age":29,"messages":["msg 1","msg 2","msg 3"],"name":"mkyong"}
To enable pretty print, just call the "defaultPrettyPrintingWriter()
” like this :
User user = new User(); ObjectMapper mapper = new ObjectMapper(); System.out.println(mapper.defaultPrettyPrintingWriter().writeValueAsString(user));
Output
{ "age" : 29, "messages" : [ "msg 1", "msg 2", "msg 3" ], "name" : "mkyong" }
See a full example.
package com.mkyong.core; import java.io.IOException; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; public class JacksonExample { public static void main(String[] args) { User user = new User(); ObjectMapper mapper = new ObjectMapper(); try { System.out.println(mapper.defaultPrettyPrintingWriter() .writeValueAsString(user)); } catch (JsonGenerationException e) { e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
[maven] pom 설정 빌드시 jar파일 target 으로 링크 되는 오류 (0) | 2014.02.14 |
---|---|
[Junit-펌] @Parameters (0) | 2013.12.23 |
[mybatis] collection 의 resultMap Null 처리 -> JSON [] (0) | 2013.11.27 |
[ehcache]-[펌] 캐시 Ehcache (0) | 2013.10.23 |
[log4j] 로그파일위치변경 (0) | 2013.10.23 |
Json 에서 null (즉 [] ) 나오도록 하는 방법
1. resultMap 을 쿼리에서 뺀다
2. resultMap의 내용이 모두 Null 이어야 한다
[Junit-펌] @Parameters (0) | 2013.12.23 |
---|---|
[JSON] Object <-> JSON (0) | 2013.12.04 |
[ehcache]-[펌] 캐시 Ehcache (0) | 2013.10.23 |
[log4j] 로그파일위치변경 (0) | 2013.10.23 |
[ibatis] ArrayList<String> arylist 파라미터에 대한 사용법 (0) | 2013.09.26 |
regdate between date_format(now() - interval 1 day, '%Y-%m-%d 00:00:00')
and date_format(now() - interval 1 day, '%Y-%m-%d 23:59:59')
mysql like 대소문자 구분 (0) | 2013.12.17 |
---|---|
id별로 구분해서 카운트하기 (0) | 2013.12.11 |
[펌]mysql rownum 구현하기 (0) | 2013.12.11 |
[펌]초보도 알아야 할 MySql 튜닝 18가지 (0) | 2013.04.29 |
[펌] mysql 5.6 향상된 기능 (0) | 2013.04.24 |
[batch] 설명 및 정리 (0) | 2014.03.18 |
---|---|
[batch] parameter 전달방법 (0) | 2014.02.03 |
어노테이션에서 타입이라는 용어 (0) | 2013.07.25 |
mysql key Holder (0) | 2013.05.13 |
[펌]Mybatis Spring Annotation 적용 샘플 (0) | 2013.05.06 |
[Spring] Spring 3.0 mvc:interceptors 설정
xml 환경 변수 읽기
- tokenizeToStringArray ( configLocation 이 여러개 일 수 있다 )
- CombinedConfiguration (링크 맨아래 샘플)
- private static CombinedConfiguration config = null; // 이런식으로 초기화에서 작업해준다
[unix] 서버에서 alias 를 통한 간단한 명령 (0) | 2014.01.23 |
---|---|
jsp파일 컴파일된 Java 파일 위치 (0) | 2014.01.17 |
[펌]JBOSS에서 JNDI DataSource설정 ( DB 설정 ) (0) | 2013.07.24 |
JSP 용량초과오류 - is exceeding the 65535 bytes limit (0) | 2013.06.18 |
startup bat 창 죽을때 (0) | 2013.03.27 |
eclipse Workspace 명 \.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ 프로젝트명
이클립스 프로젝트에 빨간색이 생길때 하는 방법 (0) | 2014.02.26 |
---|---|
[실행]이클립스에서 톰켓서버 실행(메이븐 프로젝트일때) (0) | 2014.02.20 |
[plugin]번들언어 유니코드 보는 방법 (0) | 2013.09.17 |
SVN 연결방법, check out (0) | 2013.09.13 |
이클립스 초기설정 (0) | 2013.08.28 |
[JSON] Object <-> JSON (0) | 2013.12.04 |
---|---|
[mybatis] collection 의 resultMap Null 처리 -> JSON [] (0) | 2013.11.27 |
[log4j] 로그파일위치변경 (0) | 2013.10.23 |
[ibatis] ArrayList<String> arylist 파라미터에 대한 사용법 (0) | 2013.09.26 |
[JSON] 샘플 (0) | 2013.08.22 |
web.xml
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.root</param-value>
</context-param>
log4j.xml
<appender name="dailyout" class="org.apache.log4j.DailyRollingFileAppender">
<!-- 이것은 날짜별로 로그를 남김. 파일명.확장자.DatePattern으로 정의 함-->
<param name="file" value="${webapp.root}/WEB-INF/logs/spring.log"/>
<param name="Append" value="true"/>
<param name="DatePattern" value="'.'yyMMdd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%t> [%d{yyyy-MM-dd HH:mm:ss}] [%c{1}] [%L] [%p] %m %n"/>
</layout>
</appender>
[mybatis] collection 의 resultMap Null 처리 -> JSON [] (0) | 2013.11.27 |
---|---|
[ehcache]-[펌] 캐시 Ehcache (0) | 2013.10.23 |
[ibatis] ArrayList<String> arylist 파라미터에 대한 사용법 (0) | 2013.09.26 |
[JSON] 샘플 (0) | 2013.08.22 |
[ibatis] if else 처리, null 처리 (0) | 2013.08.22 |
날짜 형식 2013-10-25 13:15:14.0
str.replaceAll("\\.0","")
Annotation Example (0) | 2013.12.05 |
---|---|
static 키워드 (0) | 2013.12.04 |
스트링 비교 (0) | 2013.09.26 |
[JAVA] 공부 ,유용한 사이트 (0) | 2013.07.19 |
[펌]소프트웨어 개발보안(시큐어 코딩) 관련 가이드 (0) | 2013.07.16 |