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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:02:05+00:00 2026-05-28T17:02:05+00:00

am new to this java world.. i just wanted to know how to convert

  • 0

am new to this java world.. i just wanted to know how to convert a db populated list to json and then call this json in javascript?

i saw many examples inputting data manually into list, but i dnt understand how to convert this list.. should i create another method or something else?

Thanks for your patience and reply.

For example, i have a list of type members

public List<Member> getMember() throws SQLException
{
       //connection 
       List<Member> listmember = new ArrayList<Member>();

    ps = con.prepareStatement(myquery);
    rs = ps.executeQuery();

    while(rs.next())
    {
      Member fsta = new Member();
      fsta.setName(rs.getString(2));
      fsta.setJan(rs.getString(6));
      fsta.setFeb(rs.getString(7));
      fsta.setMar(rs.getString(8));
      listmember .add(fsta);
    }// end of while

    return listmember ;
}

Now i want to convert the listmember to json, in return call the json in my javascript.

Hope this makes it clear now

  • 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-28T17:02:07+00:00Added an answer on May 28, 2026 at 5:02 pm

    you can create list to json array as follow:

    List<Member> listmember= getMember();
    
    JSONArray jsonArray = JSONArray.fromObject(listmember);
    

    refer Simple List to Json example

    then to send it to your wepage. in your webpage you can pass it through javascript.

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

Sidebar

Related Questions

I am new to Java Multithreading World, I wrote this program, I just wanted
I'm extremely new to Java and just wanted to confirm what Double is? Is
I know 'normal' Java, but am new to the world of servlets, containers etc.
Firstly I am new to android and Java so this is a beginners question.
I am new to creating Java web applications and came across this problem when
This is strange to me: when I run in Java byte[] data = new
I'm new to Java/Eclipse/Android, so this is probably an easy (if not stupid) question:
I'm reasonably new to Java EE, so this might be stupid.. bear with me
I've a Java String with new lines(\n), say for example String value = This
First of all, I'm fairly new to Java, so sorry if this question is

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.