holon-platform / holon-json Goto Github PK
View Code? Open in Web Editor NEWHolon Platform JSON support module.
Home Page: https://holon-platform.com
License: Apache License 2.0
Holon Platform JSON support module.
Home Page: https://holon-platform.com
License: Apache License 2.0
Using JacksonConfiguration.configure(ObjectMapper objectMapper)
I'm getting this error
Exception in thread "main" java.lang.ClassCastException: class com.google.gson.internal.LinkedTreeMap cannot be cast to class com.holonplatform.core.property.PropertyBox (com.google.gson.internal.LinkedTreeMap and com.holonplatform.core.property.PropertyBox are in unnamed module of loader 'app')
and my code is
ListPathProperty<PropertyBox> DASAENTRIES = ListPathProperty.propertyBox("dasaEntries",DasaEntries.PROPERTIES);
PropertySet<?> PROPERTIES = PropertySet.builderOf(DASAENTRIES)
.build();
PathProperty<PropertyBox> VIMSHOTTARIDASA = PathProperty.create("vimshottariDasa", PropertyBox.class)
.withConfiguration(PropertySet.PROPERTY_CONFIGURATION_ATTRIBUTE,PROPERTIES)
;
List<PropertyBox> dasaEntriesBox = propertyBox.getValue(VimshottariDasa.DASAENTRIES);
for (PropertyBox pb : dasaEntriesBox) {
System.out.println(pb);
}
The error gets popup when I use this line
for (PropertyBox pb : dasaEntriesBox) {
System.out.println(pb);
}
Please help me to resolve this error.
And revise internal packages organization to ensure the root module name hierarchy consistency
Include legacy java.util.Date
and java.sql.Date type, in addition to jdk8 java.time.*
API types
I'm trying to deserialize a json string which contains an Array.
ListPathProperty<PropertyBox> DASAENTRIES = ListPathProperty.propertyBox("dasaEntries",DasaEntries.PROPERTIES);
PropertySet<?> PROPERTIES = PropertySet.builderOf(DASAENTRIES)
.build();
PathProperty<PropertyBox> VIMSHOTTARIDASA = PathProperty.create("vimshottariDasa", PropertyBox.class)
.withConfiguration(PropertySet.PROPERTY_CONFIGURATION_ATTRIBUTE,PROPERTIES)
;
When trying to get this value from JSON string, I'm getting this exception
Exception in thread "main" java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class com.holonplatform.core.property.PropertyBox (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; com.holonplatform.core.property.PropertyBox is in unnamed module of loader 'app')
at java.base/java.util.ArrayList$Itr.forEachRemaining(ArrayList.java:999)
at com.example.application.data.test.TestJson.lambda$getDasaEntries$2(TestJson.java:234)
at java.base/java.util.Optional.ifPresent(Optional.java:176)
at com.example.application.data.test.TestJson.lambda$getDasaEntries$3(TestJson.java:232)
at java.base/java.util.Optional.ifPresent(Optional.java:176)
at com.example.application.data.test.TestJson.getDasaEntries(TestJson.java:230)
at com.example.application.data.test.TestJson.test(TestJson.java:152)
at com.example.application.data.test.TestJson.main(TestJson.java:63)
This is where I'm getting the error
responseBox.getValueIfPresent(VimshottariDasa.VIMSHOTTARIDASA)
.ifPresent(propertyBox -> {
propertyBox.getValueIfPresent(VimshottariDasa.DASAENTRIES)
.ifPresent(propertyBoxes -> {
for (PropertyBox box : propertyBoxes) { // error line
}
Looks there is some problem in casting and the below proves the same.
if (propertyBoxes.get(0) instanceof LinkedHashMap) {
LinkedHashMap<?,?> map = (LinkedHashMap<?, ?>) propertyBoxes.get(0);
map.entrySet()
.stream()
.forEach(entry -> {
write(entry.getKey() +"\t" + entry.getValue());
});
}else {
write("not sure ");
}
Could you please check this ?
Add a suitable com.fasterxml.jackson.databind.Module file under META-INF/services
And use it for the Gson and Jackson PropertyBox serializer implementations
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.