Comments (6)
Likely the Proxy class is not what you want serialized. For example, if you were using Hibernate, that library proxies data model objects loaded from the database. It does this so it can intercept method calls and potentially fetch more of the object model graph upon access. In this example, you would not want the Proxy instances shipped to a front-end Android app. Instead, you would want to properly gather together the non-Proxied object model on the server, and send that to the client (using json-io).
from json-io.
That's likely true, I doubt that we care to have the proxy data, however we are not in control of the objects that are being serialized. We just are just taking whatever comes through and trying to form it into something that we can pass through an IPC mechanism. Is there an easy way to ignore the Proxy objects? I looked into using a custom Writer that just wouldn't output anything for Proxies, but the problem is that I don't know how to match on the $Proxy1 class that java.lang.reflect.Proxy creates for these objects. Any idea how we could do this?
from json-io.
Use an Class.isAssignableCheck(). Check it against java.lang.reflect.Proxy
On Fri, May 22, 2015 at 9:05 AM, Kevin LaFlamme [email protected]
wrote:
That's likely true, I doubt that we care to have the proxy data, however
we are not in control of the objects that are being serialized. We just are
just taking whatever comes through and trying to form it into something
that we can pass through an IPC mechanism. Is there an easy way to ignore
the Proxy objects? I looked into using a custom Writer that just wouldn't
output anything for Proxies, but the problem is that I don't know how to
match on the $Proxy1 class that java.lang.reflect.Proxy creates for these
objects. Any idea how we could do this?—
Reply to this email directly or view it on GitHub
#39 (comment).
from json-io.
I understand how to check if the object is a Proxy, but how do I setup a custom Writer for any object that is proxied? I see how to set one up by adding the class to the writers map with JsonWriter.addWriter(), but I don't have a reference to the class object for $Proxy1, so is there a way to do this?
from json-io.
Set one up for Object.class - I am pretty sure it supports inheritance.
This CustomWriter would be called for all classes if associated to
Object.class. Give it a try.
On Fri, May 22, 2015 at 9:34 AM, Kevin LaFlamme [email protected]
wrote:
I understand how to check if the object is a Proxy, but how do I setup a
custom Writer for any object that is proxied? I see how to set one up by
adding the class to the writers map with JsonWriter.addWriter(), but I
don't have a reference to the class object for $Proxy1, so is there a way
to do this?—
Reply to this email directly or view it on GitHub
#39 (comment).
from json-io.
Couldn't find a way to do it with a custom writer, but we did find another way to remove the unnecessary Proxy stuff before the object gets passed to this library. Thanks so much for the quick responses.
from json-io.
Related Issues (20)
- vulnerable to Denial Of Services (DoS) HOT 2
- Exception while deserializing `SingletonList` HOT 1
- Incorrect looking tag "14.4.2" for release version 4.14.2 HOT 1
- Possible issue about list of objects that have custom writers HOT 5
- Java class version 55 for 4.14.2 HOT 3
- Revisiting issue 17 HOT 6
- Enums are serialized differently with 4.15.0 HOT 3
- 4.15 --> 4.16 default mapping method fails to parse HOT 7
- Enhance the robustness of tests
- ReadOptionsBuilder HOT 1
- Compile / runtime dependency on com.novell.ldap:jldap HOT 3
- How to deserialise javafx classes with inaccessible fields? HOT 2
- Request for tutorial HOT 2
- NoSuchMethodError after upgrade HOT 24
- Custom serialising of objects with inheritance HOT 2
- Encoding Bug for JsonIo.toJson("🙊🙉🙈", null)? HOT 3
- Custom Writers not including id and ref in output? HOT 3
- Compatibility between 4.14.0 and 4.20.0 HOT 4
- User guide Untyped Usage HOT 1
- high usage of metaspace after upgrade to 4.22.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-io.