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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:41:25+00:00 2026-05-24T05:41:25+00:00

I am trying to model a simple invoice that has an invoice object with

  • 0

I am trying to model a simple invoice that has an invoice object with minimally an ArrayList and an lineitem object with an ArrayList of the values for a given row. I get my result-set, loop over it and every time create a new lineitem object, populate the lineitem ArrayList with the desired field values and then add that lineitem to the invoice ArrayList. I then add this to a JSONArray and then “flatten” it with toString() to get my json string to send to the client. The problem is all the lines are there but as a “bare” array of lineitem objects. I need another structure that I can loop on client-side, access each lineitem object, and print the row to the screen and continue. How do I structure it so I have and “outer” object that I can loop over to process the lineitems?

  • 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-24T05:41:25+00:00Added an answer on May 24, 2026 at 5:41 am

    You need to “parse” the values / array on the server side to build up a string that can be interpreted as JSON on the client. There are lots of libraries (both server & client side that can help you with this). Ultimately you need a string that looks somthing like the following when it arrives on the client side.

    var strJsonInvoive = "[InvoiceID : 1, Date : "01/01/1900", otherProperties: "value" ,
    //the Invoice Detail Objects below will result in an array of objects
    InvoiceDetails : [InvoiceDetailID : 1, Description: "desc", Price: 100, Quantity: 1, Tax: true],
    [InvoiceDetailID : 2, Description: "desc", Price: 200, Quantity: 2, Tax: false],
    [InvoiceDetailID : 3, Description: "desc", Price: 300, Quantity: 3, Tax: true]]";
    

    At this point, the above is purely a string, so again, you need to Parse this client side to turn this into an object, for example you could use jQuery to Parse the json string as follows :

    var jsonInvoice = jQuery.parseJSON(strJsonInvoice);
    

    Now, you will have an object that you can work with as follows :

    for(var 1=0; i<jsonInvoice.InvoiceDetails.length;i++)
    {
        if (jsonInvoice.InvoiceDetails[i].Price > 50)
            //do something if price is greater than 50
    }
    

    Hope this helps.

    Dave

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

Sidebar

Related Questions

I'm writing a simple Rails model called Person that has_many :phone_numbers and I'm trying
My application has a very simple model right now and I'm trying to find
I'm trying to model this inheritance for a simple blog system Blog has many
Relatively new to rails and trying to model a very simple family tree with
Am trying to construct a simple update query in my model class Model_DbTable_Account extends
I am trying to adapt a simple WPF application to use the Model-View-ViewModel pattern.
I'm trying to model my tests after the great work that the Thougtbot guys
I've got a simple model object: class UserRating include MongoMapper::EmbeddedDocument key :idea_id, ObjectId key
I am trying to do a simple test for my model Course , I
We use a simple object model for our low level networking code at work

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.