아무거나

json parse 방법[데이터 json형태로 출력하기] 본문

Java & Kotlin/Spring

json parse 방법[데이터 json형태로 출력하기]

전봉근 2019. 6. 19. 10:16
반응형

1. pom.xml 추가

<!-- Jackson JSON Mapper -->
<dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-mapper-asl</artifactId>
    <version>1.7.1</version>
</dependency>

 

2. 컨트롤러 추가

@RequestMapping(value="/s3Bucket/{bucketName}", method= RequestMethod.GET)
public @ResponseBody S3Bucket getS3Bucket(@PathVariable String bucketName) {
    S3Bucket s3Bucket = new S3Bucket();
    s3Bucket.setBucketName(bucketName);
    return s3Bucket;
} 

 

3. 모델 추가(getter/setter 생성자)

package com.deploy.model;

public class S3Bucket {
	String bucketName;

	//getter and setter methods
    public void setBucketName(String bucketName) {
       this.bucketName = bucketName;
    }

    public String getBucketName() {
       return bucketName;
    }
}​ 

 

반응형
Comments