Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 726255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:25:51+00:00 2026-05-14T06:25:51+00:00

I am using Grails Webflow, what ever object I pass to a view, it

  • 0

I am using Grails Webflow, what ever object I pass to a view, it must be Serialized.
My domain models “implement Serializable”, so they work.

The problem is when I get a response from a WebService.
It is of the org.json.JSONArray class.

I just want to pass the whole Array over to the view yet it doesn’t implement Serializable,
so it fails,

Any thoughts on how I can pass this, or my best option?

Can I just edit the source of the org.json library and make every class “imp Serializable”?

Or process the result into Domain objects that do “imp Serializable”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:25:52+00:00Added an answer on May 14, 2026 at 6:25 am

    Wrap it as a transient property in a class which implements Serializable and has the readObject() and writeObject() overridden.

    public class SerializableJSONArray implements Serializable {
        private transient JSONArray jsonArray;
    
        public SerializableJSONArray(JSONArray jsonArray) {
            this.jsonArray = jsonArray;
        }
    
        public JSONArray getJSONArray() {
            return jsonArray;
        }
    
        private void writeObject(ObjectOutputStream oos) throws IOException {
            oos.defaultWriteObject();
            oos.writeObject(jsonArray.toString());
        }
    
        private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException, JSONException {
            ois.defaultReadObject();
            jsonArray = new JSONArray((String) ois.readObject());
        }
    }
    

    You see that there’s a getter which returns the wrapped JSONArray. Use it in your domain objects instead. Optionally you can also let this class extends JSONArray and delegate all of its methods to the wrapped JSONArray. A decent IDE can autogenerate them for you in a second.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Grails Webflow plugin. Here are the domain objects I'm working with:
I am using the webflow plugin for Grails for the first time and am
I've developed a simple webflow in Grails (mostly to experiment with using webflows- its
We have a Grails 1.3.7 Application and are using Webflow for a 2 step
I have been using Grails for some time now, but in school they are
using Grails 1.1.1 I have domain in Grails Person. Person can be related to
I'm using Grails to set properties on a domain class if the property is
I'm using Grails 1.3.7. Let's say I have the domain objects Foo and Bar
When persisting domain objects using Grails/GORM I frequently find myself wondering why a save()
I'm using Grails, and I have a domain model with multiple hasMany attributes to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.