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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:07:49+00:00 2026-06-15T22:07:49+00:00

I have a java object like that has a couple of object fields which

  • 0

I have a java object like that has a couple of object fields which have basic fields in them, here is an example:

Template {
    String name;
    EmailMessage defaultEmailMessage;
}
EmailMessage {
    String emailSubject;
    String emailBody;
}

I have a spring controller method that returns a list of templates in json format using gson.

In my jsp I use a jquery ajax call to get this list and then populate some html content based on it, here is a shortened version:

$.ajax({
    type : "GET",
    url : '<c:url value="/listTemplates.htm"/>',
    dataType: 'json',
    success : function(templates) {
    var map = $.map(templates, function(template) { 
        return { 
            "name": template.name,
            "emailSubject": template.defaultEmailMessage.emailSubject
    };});
        $("#thumbnails-ul").html($("#campaignThumbTmpl").tmpl(map));
    },
    error : function(data) {
        alert(data.responseText);
    }
});

In firebug I see an error undefined template.defaultEmailMessage but when I debug I can evaulate both template.defaultEmailMessage and template.defaultEmailMessage.emailSubject. I tried using $.each but same problem. How can I access nested json? If you want to see the full output of json in the browser, please let me know.

  • 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-15T22:07:50+00:00Added an answer on June 15, 2026 at 10:07 pm

    Replace your "emailSubject": template.defaultEmailMessage.emailSubject with "emailSubject": template.defaultEmailMessage

    ADDED LATER:
    Why do you want to convert the data into json again ? you are requesting the data as json and again you are returning the json data into the template for compilation.Put the data directly into the template.

    $.ajax({
              type:"GET",
              url:"<c:url value="/listTemplates.htm"/>",
              datatype:"application/json",
              success:function(templates){      
                       $.get("Put Your Template URL HERE",function(template}
                       var result = _.template(template);                                $("#thumbnails-ul").html($("#campaignThumbTmpl").tmpl(templates));
            });
                 }
        }); 
    

    This way you will be able to put the data wherever you want in your template by accessing it through .each loop as below:

     <% _.each(data,function(anynamehere){ %>
            <li><a href="<%= anynamehere.name %>"></li>
        <% }); %>
    

    The above is a sample to print your name from the class but with other .each loop you can put other properties too….hope this helped…

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

Sidebar

Related Questions

In Java I have an object that looks like this : class MyDoc {
I have a Java Properties object that I load from an in-memory String ,
I have a Media entity that has some basic fields for files uploaded by
I have a DSL Java object, i.e. a POJO which returns this in setters
I have a java.sql.ResultSet object containg data from a query that was run. How
Let's say I have a java.util.Properties object. The Properties object has a method called
Suppose I have a Java method that returns a HashMap object. Because a LinkedHashMap
Suppose we have the Java code: Object arr = Array.newInstance(Array.class, 5); Would that run?
I have a class MyClass that has a static variable. Class implements smth like
Let's say I have a class Foo in Java that has immutable data: class

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.