wso2 API管理器1.9中的JSON响应的xslt转换

时间:2015-10-24 16:59:48

标签: json xslt wso2 wso2-am

我有一个以这种格式的示例后端响应json:
 我想从RESPONSE和RESPONSE_ORDER标记中提取逗号分隔值,这样我就可以在输出JSON中明确地设置它们。基本上,我的输出应该是使用xslt转换的类似的东西。 使用xslt介体我想将其转换如下:

{
  "d": {
    "results": [      
      {        
        "TYPE_ID": "20",
        "QUESTION_ID": "41333",
        "RESPONSE_TYPE": "Checkboxes",
        "QUESTIONVAL": "xssdsdd",
        "RESPONSE": "Yes",
        "RESPONSE_ORDER": "1"        
      }, 
      {        
        "TYPE_ID": "21",
        "QUESTION_ID": "417",
        "RESPONSE_TYPE": "Radio buttons",
        "QUESTIONVAL": "abc",
        "RESPONSE": "Yes,No",
        "RESPONSE_ORDER": "1,2"       
      }
    ]
  }
}

转换后的示例输出

{
    "results": [      
      {        
        "TYPE_ID": "20",
        "QUESTION_ID": "41333",
        "RESPONSE_TYPE": "Checkboxes",
        "QUESTIONVAL": "xssdsdd",
        Response&Order: [
            {
            "RESPONSE": "Yes",
            "RESPONSE_ORDER": "1"
            }
        ]               
      }, 
      {        
        "TYPE_ID": "21",
        "QUESTION_ID": "417",
        "RESPONSE_TYPE": "Radio buttons",
        "QUESTIONVAL": "abc",
        Response&Order: [
            {
            "RESPONSE": "Yes",
            "RESPONSE_ORDER": "1"
            },
            {
            "RESPONSE": "No",
            "RESPONSE_ORDER": "2"
            }
        ]             
      }
    ]
}

如何拆分值以生成此类输出?

0 个答案:

没有答案