[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-19 UTC。"],[[["\u003cp\u003eApigee policies enable manipulation of messages within API proxies, including format conversion and data handling.\u003c/p\u003e\n"],["\u003cp\u003eThe JSONtoXML and XMLtoJSON policies facilitate conversion between JSON and XML formats by specifying input and output variables within the \u003ccode\u003e<Source>\u003c/code\u003e and \u003ccode\u003e<OutputVariable>\u003c/code\u003e elements, respectively.\u003c/p\u003e\n"],["\u003cp\u003eThe XSLTransform policy allows transformation of XML messages using XSL stylesheets, with similar input/output specification.\u003c/p\u003e\n"],["\u003cp\u003eThe AssignMessage and ExtractVariables policies enable the creation of messages from variable values and the extraction of message content to set variable values, respectively.\u003c/p\u003e\n"],["\u003cp\u003eFor complex data transformations beyond the scope of these built-in policies, procedural code in JavaScript, Java, or Python can be incorporated.\u003c/p\u003e\n"]]],[],null,["# Shaping, accessing, and converting messages\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\nYou can use policies included with Apigee to manipulate the messages flowing through your\nAPI proxies. With policies, you can:\n\n- Convert messages between formats, such as from XML to JSON.\n- Set variable values from message content, and create messages from variable values.\n- Use procedural code, such as JavaScript, Java, and Python, to handle messages and data in more complex ways.\n\nIn general, when using these policies, you specify input and output as a flow variables. At\nrun time, Apigee retrieves the input value from a source variable and writes the output\nvalue to an output variable.\n\nThis topic introduces these capabilities. For more complete and technical information, see the\npolicy references for each.\n\nSimple handling for XML and JSON\n--------------------------------\n\nApigee includes policies that make it easier to convert between XML and JSON, and to\ntransform XML with XSL.\n\n### Converting JSON to XML\n\nThe [JSONtoXML policy](/apigee/docs/api-platform/reference/policies/json-xml-policy) takes your JSON input and converts it to XML.\n\nIn the following policy example, the policy takes a JSON-formatted message from the\n`request` variable, then replaces the variable value with an XML-formatted message.\nThe input is specified in the `\u003cSource\u003e` element, while the output is specified\nin the `\u003cOutputVariable\u003e` element. \n\n```text\n\u003cJSONToXML name=\"jsontoxml\"\u003e\n \u003cSource\u003erequest\u003c/Source\u003e ---\u003e INPUT\n \u003cOutputVariable\u003erequest\u003c/OutputVariable\u003e OUTPUT ---\u003e\n\u003c/JSONToXML\u003e\n```\n\n### Converting XML to JSON\n\nThe [XMLtoJSON policy](/apigee/docs/api-platform/reference/policies/xml-json-policy) converts XML input message into JSON.\n\nIn the following policy example, the policy takes an XML-formatted message from the\n`response` variable, then replaces the variable value with a JSON-formatted message.\nThe input is specified in the `\u003cSource\u003e` element, while the output is specified\nin the `\u003cOutputVariable\u003e` element. \n\n```text\n\u003cXMLToJSON name=\"ConvertToJSON\"\u003e\n \u003cSource\u003eresponse\u003c/Source\u003e ---\u003e INPUT\n \u003cOutputVariable\u003eresponse\u003c/OutputVariable\u003e OUTPUT ---\u003e\n\u003c/XMLToJSON\u003e\n```\n\n### Transforming XML with XSL\n\nYou can use the [XSLTransform policy](/apigee/docs/api-platform/reference/policies/xsl-transform-policy) to transform messages using XSL. For example, after\nconverting a JSON\npayload to XML, you can use the XSL Transform policy with a style sheet to perform the\ntransformation you need.\n\nIn the following policy example, the policy takes an XML-formatted message from the\n`response` variable, then replaces the variable value with a message formatted by\n`my_transform.xsl`. The input is specified in the `\u003cSource\u003e` element,\nwhile the output is specified in the `\u003cOutputVariable\u003e` element. \n\n```scdoc\n\u003cXSL name=\"TransformXML\"\u003e\n \u003cSource\u003eresponse\u003c/Source\u003e ---\u003e INPUT\n \u003cResourceURL\u003exsl://my_transform.xsl\u003c/ResourceURL\u003e --TRANSFORMER--\n \u003cOutputVariable\u003eresponse\u003c/OutputVariable\u003e OUTPUT ---\u003e\n\u003c/XSL\u003e\n```\n\nHandling variable data\n----------------------\n\nData handling within a proxy often involves simply working with state data as flow variable\nvalues. You can often do this by using a policy that gets or sets variable values. For example,\nyou might want to shape variable values into a message, or extract the contents of a message to\nset variable values.\n\nBe sure to see references for the following two policies:\n\n- [AssignMessage policy](/apigee/docs/api-platform/reference/policies/assign-message-policy) to create messages from variable values.\n- [ExtractVariables policy](/apigee/docs/api-platform/reference/policies/extract-variables-policy) to assign variables from message content.\n\nCreating more complex transformations\n-------------------------------------\n\nFor data handling whose complexity is outside the capability of included policies, you can use\nprocedural languages such as JavaScript, Java, or Python.\n\nGenerally, this involves writing code in one of these languages, then invoking the code from a\npolicy specific to the language. For more about this, see\n[Incorporating\nprocedural code](/apigee/docs/api-platform/develop/incorporating-procedural-code-api-proxy)."]]