Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### v4.8.0 (2026-06-02)
* * *
### Enhancements:
* Added a `fromJson(Map<String, Object>)` overload to all models, so nested map entities can be converted to a typed model directly (e.g. `Subscription.fromJson(subscription)`).


### Bug Fixes:
* Fixed deserialization of nested JSON in dynamic `Map<String, Object>` fields (for example [`HostedPage.getContent()`](https://apidocs.chargebee.com/docs/api/hosted_pages/hosted-page-object#content) and [`HostedPage.getCheckoutInfo()`](https://apidocs.chargebee.com/docs/api/hosted_pages/hosted-page-object#checkout_info)). Nested objects and arrays are now returned as `Map` and `List` instead of JSON strings, which resolves `ClassCastException` when casting nested entities such as `customer`, `subscription`, and `invoice` to `Map<String, Object>`. The same parsing behavior applies to other map attributes including [`Event.getContent()`](https://apidocs.chargebee.com/docs/api/events/event-object#content), `meta_data`, and `consent_fields`. If your integration previously parsed nested map values as JSON strings, use the returned `Map`/`List` directly or branch on `instanceof` during upgrade.


### v4.7.0 (2026-05-04)
* * *
### New Resources:
Expand Down Expand Up @@ -86,7 +96,6 @@
- `mada` has been added as a new value to enum request body parameter `card.brand` in [`create_using_permanent_token`](https://apidocs.chargebee.com/docs/api/payment_sources/create-using-permanent-token) of [`PaymentSource`](https://apidocs.chargebee.com/docs/api/payment_sources).



### v4.6.0 (2026-03-27)
* * *
### New Resources:
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,24 @@ future.thenAccept(resp -> {
});
```

### Dynamic map fields (`Map<String, Object>`)

Some attributes are returned as `Map<String, Object>` for schema-less JSON (for example `HostedPage.getContent()`, `HostedPage.getCheckoutInfo()`, `Event.getContent()`, `meta_data`). Nested JSON objects become `Map`, and nested JSON arrays become `List`:

```java
Map<String, Object> content = client.hostedPages().retrieve(hostedPageId).getHostedPage().getContent();

@SuppressWarnings("unchecked")
Map<String, Object> subscription = (Map<String, Object>) content.get("subscription");
String subscriptionId = (String) subscription.get("id");
```

Every model exposes a `fromJson(Map<String, Object>)` overload, so a nested entity can be converted into a typed model by passing the map directly—no JSON string round-trip needed:

```java
Subscription typedSubscription = Subscription.fromJson(subscription);
```

### Custom Field Filtering

Filter list operations by custom fields using type-safe filters (`stringFilter()`, `numberFilter()`, `timestampFilter()`, `booleanFilter()`):
Expand Down Expand Up @@ -679,6 +697,7 @@ public class Sample {
- Immutable `ChargebeeClient` with fluent builder
- Direct property naming (e.g., `.apiKey()`, `.siteName()`)
- Type-safe request models and responses
- Dynamic `Map<String, Object>` fields deserialize nested JSON as maps and lists (see [Dynamic map fields](#dynamic-map-fields-mapstring-object))
- Sync and async APIs with retry/backoff
- Per-request options and headers
- Enhanced error handling and debugging
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.7.0
4.8.0
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "com.chargebee"
version = "4.7.0"
version = "4.8.0"
description = "Java client library for ChargeBee"

// Project metadata
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/chargebee/v4/internal/JsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static boolean hasValue(JsonObject obj, String key) {

// --- JsonObject to Map conversion ---

/** Converts a JsonObject to a Map; primitives become Java types, nested structures become JSON strings. */
/** Converts a JsonObject to a Map; primitives become Java types, nested objects become nested maps, arrays become lists. */
public static Map<String, Object> parseJsonObjectToMap(JsonObject obj) {
Map<String, Object> map = new HashMap<>();
if (obj == null) return map;
Expand Down Expand Up @@ -357,8 +357,11 @@ private static Object toJavaValue(JsonElement value) {
return prim.getAsLong();
}
}
if (value.isJsonObject() || value.isJsonArray()) {
return value.toString();
if (value.isJsonObject()) {
return parseJsonObjectToMap(value.getAsJsonObject());
}
if (value.isJsonArray()) {
return mapArrayToObjects(value.getAsJsonArray());
}
return null;
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/chargebee/v4/models/addon/Addon.java
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ public static Addon fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Addon fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Addon fromJson(JsonObject jsonObj) {
Addon obj = new Addon();

Expand Down Expand Up @@ -1021,6 +1025,10 @@ public static Tiers fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Tiers fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Tiers fromJson(JsonObject jsonObj) {
Tiers obj = new Tiers();

Expand Down Expand Up @@ -1118,6 +1126,10 @@ public static TaxProvidersFields fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static TaxProvidersFields fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static TaxProvidersFields fromJson(JsonObject jsonObj) {
TaxProvidersFields obj = new TaxProvidersFields();

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/chargebee/v4/models/address/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ public static Address fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Address fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Address fromJson(JsonObject jsonObj) {
Address obj = new Address();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public static AdvanceInvoiceSchedule fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static AdvanceInvoiceSchedule fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static AdvanceInvoiceSchedule fromJson(JsonObject jsonObj) {
AdvanceInvoiceSchedule obj = new AdvanceInvoiceSchedule();

Expand Down Expand Up @@ -187,6 +191,10 @@ public static FixedIntervalSchedule fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static FixedIntervalSchedule fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static FixedIntervalSchedule fromJson(JsonObject jsonObj) {
FixedIntervalSchedule obj = new FixedIntervalSchedule();

Expand Down Expand Up @@ -267,6 +275,10 @@ public static SpecificDatesSchedule fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static SpecificDatesSchedule fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static SpecificDatesSchedule fromJson(JsonObject jsonObj) {
SpecificDatesSchedule obj = new SpecificDatesSchedule();

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/chargebee/v4/models/alert/Alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ public static Alert fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Alert fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Alert fromJson(JsonObject jsonObj) {
Alert obj = new Alert();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public static AlertStatus fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static AlertStatus fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static AlertStatus fromJson(JsonObject jsonObj) {
AlertStatus obj = new AlertStatus();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ public static AttachedItem fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static AttachedItem fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static AttachedItem fromJson(JsonObject jsonObj) {
AttachedItem obj = new AttachedItem();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public static Attribute fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Attribute fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Attribute fromJson(JsonObject jsonObj) {
Attribute obj = new Attribute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public static BillingConfiguration fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static BillingConfiguration fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static BillingConfiguration fromJson(JsonObject jsonObj) {
BillingConfiguration obj = new BillingConfiguration();

Expand Down Expand Up @@ -83,6 +87,10 @@ public static BillingDates fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static BillingDates fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static BillingDates fromJson(JsonObject jsonObj) {
BillingDates obj = new BillingDates();

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/chargebee/v4/models/brand/Brand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public static Brand fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Brand fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Brand fromJson(JsonObject jsonObj) {
Brand obj = new Brand();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public static BusinessEntity fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static BusinessEntity fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static BusinessEntity fromJson(JsonObject jsonObj) {
BusinessEntity obj = new BusinessEntity();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ public static BusinessEntityTransfer fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static BusinessEntityTransfer fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static BusinessEntityTransfer fromJson(JsonObject jsonObj) {
BusinessEntityTransfer obj = new BusinessEntityTransfer();

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/chargebee/v4/models/card/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ public static Card fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Card fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Card fromJson(JsonObject jsonObj) {
Card obj = new Card();

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/chargebee/v4/models/comment/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ public static Comment fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Comment fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Comment fromJson(JsonObject jsonObj) {
Comment obj = new Comment();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public static Configuration fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Configuration fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Configuration fromJson(JsonObject jsonObj) {
Configuration obj = new Configuration();

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/chargebee/v4/models/contact/Contact.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public static Contact fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Contact fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Contact fromJson(JsonObject jsonObj) {
Contact obj = new Contact();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ public static ContractTerm fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static ContractTerm fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static ContractTerm fromJson(JsonObject jsonObj) {
ContractTerm obj = new ContractTerm();

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/chargebee/v4/models/coupon/Coupon.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ public static Coupon fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static Coupon fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static Coupon fromJson(JsonObject jsonObj) {
Coupon obj = new Coupon();

Expand Down Expand Up @@ -877,6 +881,10 @@ public static ItemConstraints fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static ItemConstraints fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static ItemConstraints fromJson(JsonObject jsonObj) {
ItemConstraints obj = new ItemConstraints();

Expand Down Expand Up @@ -979,6 +987,10 @@ public static ItemConstraintCriteria fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static ItemConstraintCriteria fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static ItemConstraintCriteria fromJson(JsonObject jsonObj) {
ItemConstraintCriteria obj = new ItemConstraintCriteria();

Expand Down Expand Up @@ -1115,6 +1127,10 @@ public static CouponConstraints fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static CouponConstraints fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static CouponConstraints fromJson(JsonObject jsonObj) {
CouponConstraints obj = new CouponConstraints();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public static CouponCode fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static CouponCode fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static CouponCode fromJson(JsonObject jsonObj) {
CouponCode obj = new CouponCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public static CouponSet fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static CouponSet fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static CouponSet fromJson(JsonObject jsonObj) {
CouponSet obj = new CouponSet();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public static CpqQuoteSignature fromJson(String json) {
return fromJson(JsonUtil.parse(json));
}

public static CpqQuoteSignature fromJson(java.util.Map<String, Object> map) {
return fromJson(JsonUtil.toJson(map));
}

public static CpqQuoteSignature fromJson(JsonObject jsonObj) {
CpqQuoteSignature obj = new CpqQuoteSignature();

Expand Down
Loading
Loading