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

  • SEARCH
  • Home
  • 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 8036429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:37:08+00:00 2026-06-05T02:37:08+00:00

Server side I have this Java: public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException

  • 0

Server side I have this Java:

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

    resp.setContentType("application/json;charset=UTF-8");        
    resp.setHeader("Cache-Control", "no-cache");

    PersistenceManager pm = PMF.get().getPersistenceManager();
    Extent<Video> extent = pm.getExtent(Video.class, false);

    ArrayList<Video> list = new ArrayList<Video>(); 
    for (Video e : extent) {
        list.add(e);
    }

    Gson gson = new Gson();
    String json = gson.toJson(list);
    System.out.println(json); // As expected: [{"id":34,"title":"a title","videoUrl":"an.mp4","imageUrl":"a.jpg" etc.
    resp.getWriter().write(json);

    extent.closeAll();
    pm.close();

}

Client side I have this JavaScript using jQuery:

var getAllRequest = $.ajax({ 
 url: "http://localhost:8888/getAll",
 type: "GET",
 dataType: "json"
});
getAllRequest.done(function(response) {         
 alert (response) // THIS IS AN OBJECT ARRAY, i.e., [object Object],[object Object] etc. 
});

My question: is response really a json object, or just an array of json objects.
I’m using jq grid, and it does not fill in the grid when given the response. (Feeding the response to the jq grid not shown here.)

  • 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-06-05T02:37:10+00:00Added an answer on June 5, 2026 at 2:37 am

    JSON gives you the way to post information about the object as string. So there are no “json object”. Either you have string with for example the text like

    var str = '[["a", "b"], ["c", "d"], ["e", "f"]]';
    

    or you have an object for example

    var myObj = [["a", "b"], ["c", "d"], ["e", "f"]];
    

    The full specification of JSON is described here or in rfc4627. So you should not mix the initialization syntax which allows you to create object with the JSON string with very close syntax.

    If you use $.ajax with dataType: "json" parameter and the server response contains JSON string jqGrid internally convert the server response to object (see $.parseJSON function) and the parameter of the done will be already object. So you could use

    alert(response.length);
    

    for example inside of callback function of getAllRequest.done. In any way the client seems to get correctly the server response.

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

Sidebar

Related Questions

I have a chrome extension which have a server-side javascript and I need this
I have a Java-based server side and a flex client side using Spring BlazeDS
I have an expensive server side resource ( which is thread safe ). What
If I have pages having server-side code in code-behind, then I know that the
I have a the following server side app.config for a WCF service: <system.serviceModel> <bindings>
I have created an application server side that will create a pdf of a
I have a Struts2 action in the server side for file downloading. <action name=download
I have the following node.js server-side code: var app = require('http').createServer(handler) , io =
i have a rhel 4 server and use php as a server side scripting
I currently have a control that is being hidden on my server side using

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.