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 6576741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:33:01+00:00 2026-05-25T15:33:01+00:00

Using $.getJSON my result can be empty, a single value or a list of

  • 0

Using $.getJSON my result can be empty, a single value or a list of values.

If the result contains a single value i can access the data via result.someReturnedValue however if the result contains a list i have to loop through the result data using array syntax to access the data E.g. result[i].someReturnedValue

Now i dont want to write the same code twice to handle each type of result. (I’m appending the result to DOM elements and the code is getting large when i have to account for both notations) Is there a generic way i can handle the result to prevent this duplication?

Example of single result;

    $('div[id="'+divId+'"]').append("<td>" + result.someValue1+ "</td>");
$('div[id="'+divId+'"]').append("<td>" + result.someValue2+ "</td>");
$('div[id="'+divId+'"]').append("<td>" + result.someValue2+ "</td>");

Example of multiple results:

    $('div[id="'+divId+'"]').append("<td>" + result[i].someValue1+ "</td>");
$('div[id="'+divId+'"]').append("<td>" + result[i].someValue2+ "</td>");
$('div[id="'+divId+'"]').append("<td>" + result[i].someValue2+ "</td>");
  • 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-25T15:33:02+00:00Added an answer on May 25, 2026 at 3:33 pm

    Ok i found a solution for this issue. You can create your own Provider class which Jersey will use when generating the JSON response.

    @Component
    @Provider
    public class 
    
    JAXBContextResolver implements ContextResolver<JAXBContext> {
    
    private final JAXBContext context;
    
    private final Class[] cTypes = { SomeCustomClass.class };
    
    public JAXBContextResolver() throws JAXBException {
        this.context = new JSONJAXBContext(JSONConfiguration.natural().build(),
                cTypes);
    }
    
    public JAXBContext getContext(Class<?> objectType) {
        for (Class type : cTypes) {
            if (type == objectType) {
                return context;
            }
        }
        return null;
    }
    

    This provider uses the NATURAL JSON notation, which serializes the object as required in list format.

    Ensure Spring is aware of the class by including the necessary annotations/bean definition

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

Sidebar

Related Questions

I'm using jquery $.getJSON to retrieve list of cities. Everything works fine, but I'm
I am attempting to pase a a JSON data using the JQuery getJSON function.
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
I am using $.getJSON() to pass some data to the server side (PHP, Codeigniter)
I'm currently using $.getJSON to pass an array of ids. It basically constructs a
I am using jquery and the getJSON method and I am wondering if there
Using PyObjC , you can use Python to write Cocoa applications for OS X.
We are trying to hit the meetup.com api using jquery's getJSON() method and are
I am using YQL's query.multi to grab multiple feeds so I can parse a
$(function(){ $.getJSON('http://pipes.yahoo.com/pipes/pipe.run?_id=7ba696f34ae17b6fa8f5d4de13064dea&_render=json&callback=?',function(data){alert('called')}); }); i am using the above code to acess the a yahoo

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.