* JSON 생성시 null 인 항목은 제외하도록 설정할 떄 사용.
* ex)
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@JsonInclude(Include.NON_NULL)
public class User implements Serializable
{
}
JavaScript - JSON 사용
*** 자바스크립트 ***
var json_string = '{"name": "cars","count": 30,"type": {"type1": "one","type2": "two"},"array": [{"month": "JAN","day": "31"},{"month": "NOV","day": "30"}]}';
var json = JSON.parse(json_string);
console.log(json["name"]);
=> cars
console.log(json.name);
=> cars
console.log(json.type.type1);
=> one
console.log(json["type"].type2);
=> two
console.log(json.array[0].month);
=> JAN
console.log(json.array[1].day);
=> 30
console.log(json.array.number);
=> undefined
var json_string = '{"name": "cars","count": 30,"type": {"type1": "one","type2": "two"},"array": [{"month": "JAN","day": "31"},{"month": "NOV","day": "30"}]}';
var json = JSON.parse(json_string);
console.log(json["name"]);
=> cars
console.log(json.name);
=> cars
console.log(json.type.type1);
=> one
console.log(json["type"].type2);
=> two
console.log(json.array[0].month);
=> JAN
console.log(json.array[1].day);
=> 30
console.log(json.array.number);
=> undefined
피드 구독하기:
글 (Atom)