You need to sign in to do that
Don't have an account?
lakshmi surendran
Read nested JSON
I need to read ContactID from my below JSON. I used this code to read the fieldvalue, but returning null.
StripeJSON = StripeChargeParser.parse(RestContext.request.requestBody.toString());
if (StripeJSON.type == 'charge.succeeded') {
system.debug('ContactId:'+StripeJSON.data
);
{
"id": "evt_3LAK6BBp4qEbkdeL1hyxcg7K",
"object": "event",
"data": {
"object": {
"id": "ch_3LAK6BBp4qEbkdeL1YeUC11P",
"object": "charge",
"amount": 100,
"amount_captured": 100,
"amount_refunded": 0,
"balance_transaction": "txn_3LAK6BBp4qEbkdeL1I0CRyU4",
"billing_details": {
"address": {
"city": null,
"country": null
},
"email": null,
"name": "LakshmiSuren",
"phone": null
},
"invoice": null,
"livemode": false,
"metadata": {
"ContactID": "0038J000001Q8IpQAK",
"created_by": "FormAssembly - Stripe - Reference: Form 156 / Conn. 302 / Resp. 92945"
}
}
}
}
StripeJSON = StripeChargeParser.parse(RestContext.request.requestBody.toString());
if (StripeJSON.type == 'charge.succeeded') {
system.debug('ContactId:'+StripeJSON.data
);
{
"id": "evt_3LAK6BBp4qEbkdeL1hyxcg7K",
"object": "event",
"data": {
"object": {
"id": "ch_3LAK6BBp4qEbkdeL1YeUC11P",
"object": "charge",
"amount": 100,
"amount_captured": 100,
"amount_refunded": 0,
"balance_transaction": "txn_3LAK6BBp4qEbkdeL1I0CRyU4",
"billing_details": {
"address": {
"city": null,
"country": null
},
"email": null,
"name": "LakshmiSuren",
"phone": null
},
"invoice": null,
"livemode": false,
"metadata": {
"ContactID": "0038J000001Q8IpQAK",
"created_by": "FormAssembly - Stripe - Reference: Form 156 / Conn. 302 / Resp. 92945"
}
}
}
}
while(parser.nextToken()!=null){
if(parser.getText()=='ContactID'){
System.debug(parser.nextToken());
}
}