Incorrect serialization in production build
See original GitHub issueSample code
@Serializable()
export class ApiPaginationFilters {
public page: number = 1;
@JsonProperty()
public offset: number;
constructor(
@JsonProperty()
public limit: number,
) {
}
public nextPage(): void {
this.setPage(this.page + 1);
}
public setPage(page: number): void {
this.page = page;
this.offset = (this.page - 1) * this.limit;
}
public previousPage(): void {
if (this.page === 1) {
return;
}
this.setPage(this.page + 1);
}
}
@Serializable()
export class EosagoArchiveParams extends ApiPaginationFilters {
@JsonProperty()
public state: string;
@JsonProperty({
name: 'start_date',
})
public startDate: string;
@JsonProperty({
name: 'end_date',
})
public endDate: string;
}
const params = new EosagoArchiveParams(5);
console.log(params);
console.log(serialize(params));
And this code has different console output in develop and production build of angular app.
Dev:

Prod:

Serialize instance of ApiPaginationFilters leads to same result
Declaring properties like this
@Serializable()
export class ApiPaginationFilters {
public page: number = 1;
@JsonProperty()
public offset: number;
@JsonProperty()
public limit: number;
constructor(
limit: number,
) {
this.limit = limit;
}
/* ... */
}
leads to same result too.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Inherited serializable fields lead to incorrect serialization order
This Issue is producable with kotlin >=1.3.20. Consider the following scenario with a base class: import kotlinx.serialization.
Read more >InvalidCastException when serializing and deserializing
I solved this problem by enumerating the loaded assemblies in my appdomain, looking for a matching assembly name (parsed from my AssemblyQualifiedName). Once ......
Read more >Machine Learning Model Serialization - Christopher Flynn, PhD
The most common method is to serialize the model using some particular format after training, and deserialize that model in the production ......
Read more >Rust serialization: What's ready for production today?
In this guide, we'll compare 12 serialization crates in various states of production-readiness, considering API usability and performance.
Read more >Oracle Calls Java Serialization 'A Horrible Mistake ... - Slashdot
Java object serialization bypasses all validation, permitting an attacker to construct a malformed object. Exactly how that would cause a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It works correctly now. Thanks! 😃
I published the version 3.4.2.
Tell me if it works for you 😃