I wanted to make new JSON object with org.json library, but I have noticed there is a problem with Java 14 records.
When I call
String json = new JSONObject(new Order("", "Albert", "GOOGL", "SELL", 97.9, 90L)).toString();
the fields are null.
I suppose it is because java record doesn't use old getters like getXYZ?
Is there a simple work around? I mean without using different library. Or maybe my assumptions are incorrect.
public record Order(
String id,
String userId,
String securityId,
String type,
Double price,
Long quantity
) {
}
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220320</version>
</dependency>
