Skip to content

Commit 5880465

Browse files
authored
Add better example for accessing non-documented properties in a list response (#2218)
1 parent 373cf5b commit 5880465

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ If you are not using Gradle or Maven, you will need to manually install the foll
5555
- We recommend using the same version of Gson if possible to guarantee compatibility, but you should be able to use any stable version of Gson that is 2.10.1 or newer
5656

5757
To use these JARs:
58+
5859
1. Download the JARs from the links provided above
5960
2. Add the JARs to your project's classpath
6061

@@ -241,6 +242,32 @@ String secondaryValue =
241242
.getAsString();
242243
```
243244

245+
> [!NOTE]
246+
> `.getRawJsonObject()` is only available on the top-level object returned by an API call. For most requests (like `.retrieve()` or `.create()`) you'll get the object itself. But for `.list()` calls, the top level object is a `List<T>`, so you can only access the raw json of an individual object by going through the list itself.
247+
>
248+
> ```java
249+
> var cards = stripeClient
250+
> .v1()
251+
> .issuing()
252+
> .cards()
253+
> .list(params);
254+
>
255+
> // doesn't work:
256+
> cards
257+
> .getData()
258+
> .get(0)
259+
> .getRawJsonObject(); // null
260+
>
261+
> // instead, go through the list:
262+
> cards
263+
> .getRawJsonObject()
264+
> .getAsJsonArray("data")
265+
> .get(0)
266+
> .getAsJsonObject()
267+
> .getAsJsonPrimitive("undocumented-val")
268+
> .getAsString(); // "some-val"
269+
> ```
270+
244271
### Writing a plugin
245272
246273
If you're writing a plugin that uses the library, we'd appreciate it if you
@@ -269,7 +296,7 @@ Stripe.enableTelemetry = false;
269296
Stripe has features in the [public preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `-beta.X` suffix like `25.2.0-beta.2`.
270297
We would love for you to try these as we incrementally release new features and improve them based on your feedback.
271298

272-
To install, pick the latest version with the `beta` suffix by reviewing the [releases page](https://github.com/stripe/stripe-java/releases/) and then use it [installation steps above](#installation).
299+
To install, pick the latest version with the `beta` suffix by reviewing the [releases page](https://github.com/stripe/stripe-java/releases/) and then use it [installation steps above](#installation).
273300

274301
> **Note**
275302
> There can be breaking changes between two versions of the public preview SDKs without a bump in the major version. Therefore we recommend pinning the package version to a specific version. This way you can install the same version each time without breaking changes unless you are intentionally looking for the latest public preview SDK.
@@ -279,6 +306,7 @@ Some preview features require a name and version to be set in the `Stripe-Versio
279306
```java
280307
Stripe.addBetaVersion("feature_beta", "v3");
281308
```
309+
282310
### Private Preview SDKs
283311

284312
Stripe has features in the [private preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `-alpha.X` suffix like `25.2.0-alpha.2`. These are invite-only features. Once invited, you can install the private preview SDKs by following the same instructions as for the [public preview SDKs](https://github.com/stripe/stripe-java?tab=readme-ov-file#public-preview-sdks) above and replacing the term `beta` with `alpha`.

0 commit comments

Comments
 (0)