JSON Expression

김와티·2022년 12월 4일
0

slack-app-api

목록 보기
1/2

ResponseJson, JObject - SelectToken, SelectTokens

XPathJSONPathDescription
/$the root object/element
.@the current object/element
/. or []child operator
..n/arecursive descent. JSONPath borrows this syntax from E4X.
//[]wildcard. All objects/elements regardless their names.
**wildcard. All objects/elements regardless their names.
@n/aattribute access. JSON structures don't have attributes.
[][]subscript operator. XPath uses it to iterate over element collections and for predicates. In Javascript and JSON it is the native array operator.
|[,]Union operator in XPath results in a combination of node sets. JSONPath allows alternate names or array indices as a set.
n/a[start:end:step]array slice operator borrowed from ES4.
[]?()applies a filter (script) expression.
n/a()script expression, using the underlying script engine.
()n/agrouping in Xpath

  • 예시1
JObject.SelectToken("ok")					// [True]
JObject.SelectToken("channels[0].name")  	// [채널명]
  • 예시2 - Json 노드에 이름이 없는 경우
[
  {
  "id": "example_id1",
  "name": "uipath_rpa1",
  },
  {
  "id": "example_id2",
  "name": "uipath_rpa2",
  },
  ...
]
# VB.NET

JObject.SelectToken("[0].id")							// [example_id1] <JValue>
JObject.SelectToken("[1].id")							// [example_id2] <JValue>
JObject.SelectToken("$..[?(@.name=='uipath_rpa1')]")	// <JObject>
JObject.SelectToken("$..[?(@.name=='uipath_rpa1')]").SelectToken("id")	// [example_id1] <JValue>

# Multiple selct case (slack channel response)
responseConversationList("channels").SelectTokens("[0].id")
responseConversationList("channels").SelectTokens("[0].name")
responseConversationList("channels").SelectTokens("..name")
responseConversationList("channels").SelectTokens("..id")
responseConversationList("channels").SelectTokens("..name")
responseConversationList("channels").SelectTokens("..is_private")

출처 & 참고 링크

profile
딸 바보, SYOON 사랑해, RPA 운영/개발 공유하고자 하는 사람. RPA와 연계 필요한 대상은 가리지 않고 습득한다는 마음으로

0개의 댓글