package com.blogspot.na5cent; import java.util.Date; import java.util.HashMap; import java.util.Map; import org.json.simple.JSONObject; public class Test { public static void main(String[] args) { JSONObject json = new JSONObject(); Map<String, Object> data = new HashMap<String, Object>(); data.put("firstName", "redcrow"); data.put("lastName", "na5cent"); data.put("birthday", new Date(1989, 01, 01)); data.put("address", "bangkok"); data.put("age", 23); json.putAll(data); System.out.println(json.toJSONString()); } }
{ "lastName":"na5cent", "birthday":Fri Feb 01 00:00:00 ICT 3889, "address":"bangkok", "age":23, "firstName":"redcrow" }
ไม่มีความคิดเห็น:
แสดงความคิดเห็น