JsonStructNew ÇÔ¼ö´Â »õ·Î¿î JSON °´Ã¼({}) ¶Ç´Â ¹è¿([])À» »ý¼ºÇÑ´Ù.
JSON °´Ã¼´Â ÇÑ ½º·¹µå´ç ÃÖ´ë 1000°³±îÁö »ý¼º °¡´ÉÇϸç, Ãʰú ½Ã ÀÚµ¿À¸·Î ¸ðµÎ ¸®¼ÂµÈ´Ù.
object @JsonStructNew(string type);
ÇÔ¼öÀÎÀÚ
string type :
"{}" JSON °´Ã¼ »ý¼º
"[]" JSON ¹è¿ »ý¼º
¹Ýȯ °ª
¼º°ø ½Ã »ý¼ºµÈ JSON °´Ã¼ÀÇ ID (string), Çü½ÄÀº "JsonStruct_¹øÈ£" (¿¹: "JsonStruct_1")
½ÇÆÐ ½Ã ºó ¹®ÀÚ¿ ¹Ýȯ
¿¹Á¦ 1)
// 1. JSON °´Ã¼ »ý¼º
string jsonObj = @JsonStructNew("{}");
// 2. ¼Ó¼º ¼³Á¤
@JsonSet(jsonObj, "name", "È«±æµ¿", "string");
@JsonSet(jsonObj, "age", 30,
"int");
@JsonSet(jsonObj, "isActive", true, "bool");
// 3. Áßø °´Ã¼ »ý¼º
string addressObj = @JsonStructNew("{}");
@JsonSet(addressObj, "city", "¼¿ï",
"string");
@JsonSet(addressObj, "zipcode", "12345", "string");
// 4.
Áßø °´Ã¼ Ãß°¡
@JsonSet(jsonObj, "address", addressObj);
// 5. ¹è¿ »ý¼º
string phoneArray = @JsonStructNew("[]");
@JsonAppend(phoneArray,
"010-1234-5678", "string");
@JsonAppend(phoneArray, "02-123-4567", "string");
// 6. ¹è¿ Ãß°¡
@JsonSet(jsonObj, "phoneNumbers", phoneArray);
// 7.
JSON ¹®ÀÚ¿·Î º¯È¯
string jsonString = @JsonToString(jsonObj);
@MessageBox(jsonString, "jsonString", MB_OK);
// 8. ¸Þ¸ð¸® Á¤¸®
@JsonClear(jsonObj);
@JsonClear(addressObj);
@JsonClear(phoneArray);
¿¹Á¦ 2)
| // ÁÖ¹® °´Ã¼ »ý¼º string orderObj = @JsonStructNew("{}"); object t = @DateTimeNow(); string dateTimeString = @DateTimeGetString(t); @JsonSet(orderObj, "orderId", "ORD-2025-001", "string"); @JsonSet(orderObj, "orderDate", dateTimeString, "datetime:yyyy-MM-dd HH:mm:ss"); @JsonSet(orderObj, "totalAmount", 250000, "int"); // °í°´ Á¤º¸ °´Ã¼ string customerObj = @JsonStructNew("{}"); @JsonSet(customerObj, "id", "CUST001", "string"); @JsonSet(customerObj, "name", "È«±æµ¿", "string"); @JsonSet(customerObj, "email", "hong@example.com", "string"); @JsonSet(orderObj, "customer", customerObj); // ¹è¼ÛÁö Á¤º¸ °´Ã¼ string shippingObj = @JsonStructNew("{}"); @JsonSet(shippingObj, "address", "¼¿ï½Ã °³²±¸ Å×Çì¶õ·Î 123", "string"); @JsonSet(shippingObj, "contactPhone", "010-1234-5678", "string"); @JsonSet(orderObj, "shipping", shippingObj); // ÁÖ¹® Ç׸ñ ¹è¿ string itemsArray = @JsonStructNew("[]"); // ù¹øÂ° Ç׸ñ string item1 = @JsonStructNew("{}"); @JsonSet(item1, "productId", "P001", "string"); @JsonSet(item1, "name", "½º¸¶Æ®Æù", "string"); @JsonSet(item1, "quantity", 1, "int"); @JsonSet(item1, "price", 150000, "int"); @JsonAppend(itemsArray, item1); // µÎ¹øÂ° Ç׸ñ string item2 = @JsonStructNew("{}"); @JsonSet(item2, "productId", "P002", "string"); @JsonSet(item2, "name", "º¸Á¶¹èÅ͸®", "string"); @JsonSet(item2, "quantity", 2, "int"); @JsonSet(item2, "price", 50000, "int"); @JsonAppend(itemsArray, item2); // Ç׸ñ ¹è¿ Ãß°¡ @JsonSet(orderObj, "items", itemsArray); // ÃÖÁ¾ JSON ¹®ÀÚ¿ »ý¼º string finalJson = @JsonToString(orderObj); // ¸®¼Ò½º Á¤¸® @JsonClear(orderObj); @JsonClear(customerObj); @JsonClear(shippingObj); @JsonClear(itemsArray); @JsonClear(item1); @JsonClear(item2); |
ÃÖÁ¾ JSON ¹®ÀÚ¿ { "orderId": "ORD-2025-001", "orderDate": "2025-03-19 14:30:45", "totalAmount": 250000, "customer": { "id": "CUST001", "name": "È«±æµ¿", "email": "hong@example.com" }, "shipping": { "address": "¼¿ï½Ã °³²±¸ Å×Çì¶õ·Î 123", "contactPhone": "010-1234-5678" }, "items": [ { "productId": "P002", "name": "º¸Á¶¹èÅ͸®", "quantity": 2, "price": 50000 }, { "productId": "P001", "name": "½º¸¶Æ®Æù", "quantity": 1, "price": 150000 } ] } |
¹öÀüÁ¤º¸
ÃÖÃÊÁö¿ø: 10.3.6.25
°ü·Ã Ç׸ñ)
JsonTemplateReplacePlaceholder