on ‎2020 Feb 06 4:19 AM
Dear Expert,
I need your advise
how can i get the data from this json ?
{
"status": "success",
"code": "SSR001",
"message": "Order Exist",
"order_number": "2817183923949",
"order_date": "2018-12-28 10:29:03",
"delivery_method": "Link",
"data": [
{
"id_voucher": "IDTEST119",
"kode_voucher": "S0RWMTE5",
"tgl_expired": "2019-12-31",
"url": "https://cxxx.me/f39b9a51250556be8924b85da9558e6b/1537176870"
},
{
"id_voucher": "IDTEST334",
"kode_voucher": "S0RWMzM0",
"tgl_expired": "2019-12-31",
"url": " https://cxxx.me/g39b9a31250556be8924b85da9558e6b/1537176871";
}
],
"current_page": 1,
"total_page": 1,
"maximal_record": 10,
"total_record": 2
}
do you have idea ?
if have tried with this code but i'm feel lost
/*
The integration developer needs to create the method processData
This method takes Message object of package com.sap.gateway.ip.core.customdev.util
which includes helper methods useful for the content developer:
The methods available are:
public java.lang.Object getBody()
public void setBody(java.lang.Object exchangeBody)
public java.util.Map<java.lang.String,java.lang.Object> getHeaders()
public void setHeaders(java.util.Map<java.lang.String,java.lang.Object> exchangeHeaders)
public void setHeader(java.lang.String name, java.lang.Object value)
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
public void setProperties(java.util.Map<java.lang.String,java.lang.Object> exchangeProperties)
public void setProperty(java.lang.String name, java.lang.Object value)
public java.util.List<com.sap.gateway.ip.core.customdev.util.SoapHeader> getSoapHeaders()
public void setSoapHeaders(java.util.List<com.sap.gateway.ip.core.customdev.util.SoapHeader> soapHeaders)
public void clearSoapHeaders()
*/
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.*
def Message processData(Message message) {
//Properties
def map = message.getProperties()
def effectiveStartDate = map.get("effectiveStartDate")
def externalCode = map.get("externalCode")
def transactionSequence = map.get("transactionSequence")
//Body
def body = message.getBody(String.class)
def jsonSlurper = new JsonSlurper()
def list = jsonSlurper.parseText(body)
def status = list.status.toString()
def kode_voucher = list.kode_voucher.toString()
body = [cust_TransactionWallet2: [
effectiveStartDate: effectiveStartDate,
externalCode: externalCode,
transactionSequence: transactionSequence,
cust_status: status,
cust_notes: kode_voucher,
]]
def json_str = JsonOutput.toJson(body)
message.setBody(json_str);
return message;
}
Request clarification before answering.
Hello Achmad,
Below will do the needful.
def Message processData(Message message)
{
def Output="";
//Body
def body = message.getBody(String);
def jsonSlurper = new JsonSlurper()
def list = jsonSlurper.parseText(body as String)
list.data.each
{
Output=Output+"url: "+it.url+"\n"
}
message.setBody(Output.toString())
return message;
}
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.