JsonStringGetValue

 

JsonStringGetValue ÇÔ¼ö´Â JSON ¹®ÀÚ¿­¿¡¼­ JSONPath Ç¥Çö½ÄÀ¸·Î °ªÀ» Á÷Á¢ Á¶È¸ÇÑ´Ù.

 

string @JsonStringGetValue(string source, string jsonPath);

 

ÇÔ¼öÀÎÀÚ

string source     : ´ë»ó JSON ¹®ÀÚ¿­

string jsonPath  : °ªÀ» Á¶È¸ÇÒ JSONPath Ç¥Çö½Ä

 

¹Ýȯ °ª

¼º°ø ½Ã °æ·Î¿¡ ÇØ´çÇÏ´Â °ª (¿©·¯ °ªÀÌ Á¶È¸µÇ¸é ½°Ç¥·Î ±¸ºÐµÈ ¹®ÀÚ¿­ ¹Ýȯ)

½ÇÆÐ ½Ã ºó ¹®ÀÚ¿­

 

Âü°í. JSONPath Ç¥Çö½Ä ¿¹
$.name: ÃÖ»óÀ§ °´Ã¼ÀÇ "name" ¼Ó¼º
$.address.city: Áßø °´Ã¼ÀÇ "city" ¼Ó¼º
$.items[0]: ¹è¿­ÀÇ Ã¹ ¹øÂ° ¿ä¼Ò
$.items[*]: ¸ðµç ¹è¿­ ¿ä¼Ò
$..name: °´Ã¼ Æ®¸®¿¡¼­ ¸ðµç "name" ¼Ó¼º
$.items[?(@.price>10)]: Á¶°Ç¿¡ ¸Â´Â ¹è¿­ ¿ä¼Ò (price°¡ 10º¸´Ù Å« ¿ä¼Ò)

  

 

¿¹Á¦ )

//¾Æ·¡ JSON ¹®ÀÚ¿­ÀÌ ¹®ÀÚ¿­ º¯¼ö jsonStringÀÇ ÇöÀç °ªÀ̶ó°í °¡Á¤
{
"products": [
    {"id": 1, "name": "³ëÆ®ºÏ", "price": 1200000},
    {"id": 2, "name": "¸ð´ÏÅÍ", "price": 350000},
    {"id": 3, "name": "Űº¸µå", "price": 120000}
    ]
}

// Á÷Á¢ ¹®ÀÚ¿­¿¡¼­ °ª ÃßÃâ
string secondProductName = @JsonStringGetValue(jsonString, "$.products[1].name");
// °á°ú: "¸ð´ÏÅÍ"

// ¹è¿­ÀÇ ¸ðµç °¡°Ý ÃßÃâ
string allPrices = @JsonStringGetValue(jsonString, "$.products[*].price");
// °á°ú: "1200000,350000,120000"

 

¹öÀüÁ¤º¸

ÃÖÃÊÁö¿ø: 10.3.6.25

 

°ü·Ã Ç׸ñ)

JsonStructNew

JsonAppend

JsonSet

JsonToString

JsonClear

JsonGet

JsonFromString

JsonSetValue

JsonGetValue

JsonClearAll

JsonStringGetValue

JsonStringSetValue

JsonTemplateLoad

JsonTemplateReplacePlaceholder

JsonTemplateReplaceDone

JsonTemplateReplaceMissing

JsonTemplateTagSet