기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
참고
이제 우리는 주로 APPSYNC_JS 런타임과 해당 문서를 지원합니다. 여기에서 APPSYNC_JS 런타임과 해당 안내서를 사용해 보세요.
$util.xml
에는 XML 응답을 JSON 또는 사전으로 쉽게 변환할 수 있도록 하는 도우미 메서드가 포함되어 있습니다.
$util.xml 유틸리티 목록
$util.xml.toMap(String) : Map
-
XML 문자열을 사전으로 변환합니다.
Input: <?xml version="1.0" encoding="UTF-8"?> <posts> <post> <id>1</id> <title>Getting started with GraphQL</title> </post> </posts> Output (JSON representation): { "posts":{ "post":{ "id":1, "title":"Getting started with GraphQL" } } } Input: <?xml version="1.0" encoding="UTF-8"?> <posts> <post> <id>1</id> <title>Getting started with GraphQL</title> </post> <post> <id>2</id> <title>Getting started with AWS AppSync</title> </post> </posts> Output (JSON representation): { "posts":{ "post":[ { "id":1, "title":"Getting started with GraphQL" }, { "id":2, "title":"Getting started with AWS AppSync" } ] } }
$util.xml.toJsonString(String) : String
-
XML 문자열을 JSON 문자열로 변환합니다. 출력이 문자열인 것을 제외하면 toMap과 비슷합니다. 이는 HTTP 객체에서 JSON으로 XML 응답을 직접 변환하고 반환하고자 하는 경우 유용합니다.
$util.xml.toJsonString(String, Boolean) : String
-
XML 문자열을 선택 사항인 부울 파라미터가 포함된 JSON 문자열로 변환하여 JSON으로 인코딩하고자 하는지 판단합니다.