Coder Social home page Coder Social logo

Comments (6)

jdereg avatar jdereg commented on August 26, 2024

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.

lamflam avatar lamflam commented on August 26, 2024

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.

jdereg avatar jdereg commented on August 26, 2024

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.

lamflam avatar lamflam commented on August 26, 2024

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.

jdereg avatar jdereg commented on August 26, 2024

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.

lamflam avatar lamflam commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.