function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Cubs 42Cubs 42 

having trouble phasing a Json.

hi,

I am having a lot of trouble phasing this Json get the customer and subscriptions out of the data. wondering if someone could help.
 
{
  "id": "evt_1E3WsQLoXENPhT9XccQX3cWm",
  "object": "event",
  "api_version": "2018-09-24",
  "created": 1550099449,
  "data": {
    "object": {
      "id": "cus_EWa2QH7ZQLe6QD",
      "object": "customer",
      "account_balance": 0,
      "created": 1550099447,
      "currency": "aud",
      "default_source": null,
      "delinquent": false,
      "description": null,
      "discount": null,
      "email": null,
      "invoice_prefix": "B7409C7",
      "invoice_settings": {
        "custom_fields": null,
        "footer": null
      },
      "livemode": false,
      "metadata": {
        "supplierId": "40763"
      },
      "shipping": null,
      "sources": {
        "object": "list",
        "data": [

        ],
        "has_more": false,
        "total_count": 0,
        "url": "/v1/customers/cus_EWa2QH7ZQLe6QD/sources"
      },
      "subscriptions": {
        "object": "list",
        "data": [
          {
            "id": "sub_EWa2VTwVYCLme1",
            "object": "subscription",
            "application_fee_percent": null,
            "billing": "charge_automatically",
            "billing_cycle_anchor": 1550099449,
            "billing_thresholds": null,
            "cancel_at": null,
            "cancel_at_period_end": false,
            "canceled_at": null,
            "created": 1550099449,
            "current_period_end": 1552518649,
            "current_period_start": 1550099449,
            "customer": "cus_EWa2QH7ZQLe6QD",
            "days_until_due": null,
            "default_source": null,
            "discount": null,
            "ended_at": null,
            "items": {
              "object": "list",
              "data": [
                {
                  "id": "si_EWa29P6l36rROx",
                  "object": "subscription_item",
                  "billing_thresholds": null,
                  "created": 1550099449,
                  "metadata": {
                  },
                  "plan": {
                    "id": "plan_ELouSNjcX75qtE",
                    "object": "plan",
                    "active": true,
                    "aggregate_usage": "sum",
                    "amount": null,
                    "billing_scheme": "tiered",
                    "created": 1547617720,
                    "currency": "aud",
                    "interval": "month",
                    "interval_count": 1,
                    "livemode": false,
                    "metadata": {
                      "plan_code": "supplier"
                    },
                    "nickname": "Supplier Connections",
                    "product": "prod_DxNq5IpOJWmkEk",
                    "tiers": [
                      {
                        "flat_amount": 0,
                        "unit_amount": null,
                        "up_to": 5
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 400,
                        "up_to": 100
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 380,
                        "up_to": 200
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 360,
                        "up_to": 400
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 340,
                        "up_to": 500
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 320,
                        "up_to": 600
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 300,
                        "up_to": 700
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 280,
                        "up_to": 800
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 260,
                        "up_to": 900
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 240,
                        "up_to": 1000
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 240,
                        "up_to": 1200
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 220,
                        "up_to": 1300
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 180,
                        "up_to": 1500
                      },
                      {
                        "flat_amount": null,
                        "unit_amount": 160,
                        "up_to": null
                      }
                    ],
                    "tiers_mode": "graduated",
                    "transform_usage": null,
                    "trial_period_days": null,
                    "usage_type": "metered"
                  },
                  "subscription": "sub_EWa2VTwVYCLme1"
                }
              ],
              "has_more": false,
              "total_count": 1,
              "url": "/v1/subscription_items?subscription=sub_EWa2VTwVYCLme1"
            },
            "livemode": false,
            "metadata": {
            },
            "plan": {
              "id": "plan_ELouSNjcX75qtE",
              "object": "plan",
              "active": true,
              "aggregate_usage": "sum",
              "amount": null,
              "billing_scheme": "tiered",
              "created": 1547617720,
              "currency": "aud",
              "interval": "month",
              "interval_count": 1,
              "livemode": false,
              "metadata": {
                "plan_code": "supplier"
              },
              "nickname": "Supplier Connections",
              "product": "prod_DxNq5IpOJWmkEk",
              "tiers": [
                {
                  "flat_amount": 0,
                  "unit_amount": null,
                  "up_to": 5
                },
                {
                  "flat_amount": null,
                  "unit_amount": 400,
                  "up_to": 100
                },
                {
                  "flat_amount": null,
                  "unit_amount": 380,
                  "up_to": 200
                },
                {
                  "flat_amount": null,
                  "unit_amount": 360,
                  "up_to": 400
                },
                {
                  "flat_amount": null,
                  "unit_amount": 340,
                  "up_to": 500
                },
                {
                  "flat_amount": null,
                  "unit_amount": 320,
                  "up_to": 600
                },
                {
                  "flat_amount": null,
                  "unit_amount": 300,
                  "up_to": 700
                },
                {
                  "flat_amount": null,
                  "unit_amount": 280,
                  "up_to": 800
                },
                {
                  "flat_amount": null,
                  "unit_amount": 260,
                  "up_to": 900
                },
                {
                  "flat_amount": null,
                  "unit_amount": 240,
                  "up_to": 1000
                },
                {
                  "flat_amount": null,
                  "unit_amount": 240,
                  "up_to": 1200
                },
                {
                  "flat_amount": null,
                  "unit_amount": 220,
                  "up_to": 1300
                },
                {
                  "flat_amount": null,
                  "unit_amount": 180,
                  "up_to": 1500
                },
                {
                  "flat_amount": null,
                  "unit_amount": 160,
                  "up_to": null
                }
              ],
              "tiers_mode": "graduated",
              "transform_usage": null,
              "trial_period_days": null,
              "usage_type": "metered"
            },
            "quantity": 1,
            "schedule": null,
            "start": 1550099449,
            "status": "active",
            "tax_percent": 10.0,
            "trial_end": null,
            "trial_start": null
          }
        ],
        "has_more": false,
        "total_count": 1,
        "url": "/v1/customers/cus_EWa2QH7ZQLe6QD/subscriptions"
      },
      "tax_info": null,
      "tax_info_verification": null
    },
    "previous_attributes": {
      "currency": null
    }
  },
  "livemode": false,
  "pending_webhooks": 3,
  "request": {
    "id": "req_Is4MSbnoDdu4pi",
    "idempotency_key": null
  },
  "type": "customer.updated"
}

 
nox pcnox pc
Kindly let me if you are able to fix it dude, I am also facing the same issue and luckly you have already posted it.
Thank you in advance.
Yours Nox (https://noxforpc.com/).
Andrew GAndrew G
Visit this site to get a code class that mimics the JSON structure
https://json2apex.herokuapp.com/

Then, assuming a RESTful controller is required, something like
@RestResource(urlMapping='/api/Subscription/*')
global with sharing class RESTSubscriptionController {

@HttpPost
    global static boolean createSubscriptions() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;

        try
        {
            JSON2Apex jsn = (JSON2Apex)JSON.deserialize(req.requestBody.toString(), JSON2Apex.class);
            System.debug( jsn.subDetails.id );
            System.debug( jsn.subDetails.object );
        }
        catch(DMLException de)
        {
//exception handler here
        }
        return true;
    }
}

 
nox pcnox pc
Sure Andrew G sir :D thanks.
kellerman petersonkellerman peterson
Order Authentic Document Services, driver’s license, EU citizen, EU Passport,finnish id card,finnish drivers license,netherlands license,german drivers license,usa green card,usa permanent residence, fake diploma ,samples certificates, fake english degree certificate, us fake hr cert program, fake id passport, fake online lawyer diploma, Fake Passports, fake proof of address ,genuine document ,ID card, identities ,IELTS CERTIFICATE, New Identity ,fake passport online maker ,bank statements ,novelty documents passport, passport renewals ,Payment Terms, phony psychology qualifications producers , replace your docs usa, services Telepoint Code, testimonials ,testimonials and documents  ,Uk Passport ,uk passport copy buy ,bank guarantee,bank statement,us passport renewal,cheap fake id ,make a fake id ,buy a bank guarantee,fake payslips online ,replacement payslips uk,faking a college degree,college diploma online ,fake degree and transcripts,passport documents required,
scannable fake id ,where can i buy a fake id ,24 hour passport,expedited passport renewal,we supply perfectly reproduced fake money with holograms and all security features available.Indistinguishable to the eye and to touch.the latest technology we use make our notes look a 
https://www.onlinepassportproducers.com/author/onlinepassportproducers/
https://www.onlinepassportproducers.com/buy-fake-drivers-license/