#isaac.mk-Json

1 messages · Page 1 of 1 (latest)

tepid imp
#

Stripe API to deserialize a json? If you use official Stripe SDK you wouldn't need to do that

split monolith
#

When I use this, why it remind me Cannot access com.google.gson.Gson

tepid imp
#

Is that Java?

split monolith
#

yes ,it is java

tepid imp
#

Do you use Stripe Java SDK?

split monolith
#

<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
</dependency>

#

yes I use it.

tepid imp
#

Look at the response, it's an object already

{
  "object": "list",
  "url": "/v1/balance_transactions",
  "has_more": false,
  "data": [
    {
      "id": "txn_1J0LdfEmaib10qkRWsvIwTGj",
      "object": "balance_transaction",
      "amount": 107269819,
      "available_on": 1623801600,
      "created": 1623222947,
      "currency": "jpy",
      "description": null,
      "exchange_rate": 1.0727,
      "fee": 3861713,
      "fee_details": [
        {
          "amount": 3861713,
          "application": null,
          "currency": "jpy",
          "description": "Stripe processing fees",
          "type": "stripe_fee"
        }
      ],
      "net": 103408106,
      "reporting_category": "charge",
      "source": "ch_1J0LdfEmaib10qkRbiut5HJQ",
      "status": "available",
      "type": "charge"
    },
    {...},
    {...}
  ]
}
split monolith
#

But when I use RPC, I can't deserialize the BalanceTransaction since it has a null value in the source

tepid imp
#

RPC? Can you elaborate on that?

split monolith
#

Remote Procedure Call Protocol

tepid imp
#

To clarify, Stripe SDK send REST API under the hood, which is json. RPC is a different protocol and it has nothing to do with REST API

#

Yes I know the acronym

split monolith
#

OK thank you . I think my problem has solved

tepid imp
#

That's not necessary if you are using Stripe Java SDK

split monolith
#

yes I use feign

#

but

#

it gives me an error

#

feign.codec.DecodeException: Error while extracting response for type [java.util.List<com.stripe.model.BalanceTransaction>] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: null; nested exception is com.fasterxml.jackson.databind.JsonMappingException: N/A at [Source: (PushbackInputStream); line: 1, column: 526] (through reference chain: java.util.ArrayList[0]->com.stripe.model.BalanceTransaction["sourceObject"])

tepid imp
#

You shouldn't use feign with Stripe Java SDK

#

don't mix them up

#

for Stripe related logic, just forget feign and use our SDK methods