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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:22:45+00:00 2026-05-16T01:22:45+00:00

I am using this array( as an example) http://pastebin.com/M0ZJgAVs i am using json_encode() on

  • 0

I am using this array( as an example)
http://pastebin.com/M0ZJgAVs

i am using json_encode() on it and fetching it using javascript

does anyone care to tell me

to get the num rows would i simply use

var numrows = json['numrows'];

and to loop over each row
would i use

for(row in json['rows']) {
}

and then inside that to get to each datapoint would i just use

for(data in row) {

}

or am i completely off track?

  • 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-16T01:22:45+00:00Added an answer on May 16, 2026 at 1:22 am

    If you receive the deserialized JSON data in the JavaScript as an object json, then the code could looks like following

    var rows = json.rows; // cache json.rows array in a variable for better performance
    for (var iRow=0, cRows = rows.length; iRow<cRows; iRow++) {
        var row = rows[iRow];
        for (var iData=0, cData = row.length; iData<cData; iData++) {
            var data = row[iData];
            // do something with the data like
            // alert(data);
        }
    }
    

    In general you receive typically JSON data in deserialized form as an object (if you use jQuery.ajax for example). So the access of the data in JavaScript is very simple. It is just accessing of the fields of the object or accessing of the elements of the array. For performance purpose only it is better to use always an indexed loop as a "for in" loop (see http://www.jslint.com/lint.html#forin). If you access a property of an object (like the property rows) it is always better to use dotted notation (json.rows) as an index notation (json[rows]). And the last recommendation is caching property value in a local variable (like var row=rows[iRow] or var cRows = rows.length) always if you access the property more as one time.

    You can find interesting information from http://jquery-howto.blogspot.com/2009/06/javascript-for-loop-vs-jquery-each.html about the more effective way to enumerate data in the array (read also the last version of the suggested loop in the comment).

    It is also a good idea to verify your JavaScript code in JSLint (see http://www.jslint.com/).

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

Sidebar

Related Questions

I have an array list of objects and I am using this example to
I'm using this JavaScript to iterate through an array and find a matching array
I'm using this approach to store data in a global array hosting an http
For example using this Wikipedia dump: http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=lebron%20james&rvprop=content&redirects=true&format=xmlfm Is there an existing library for Python
I am doing something very similar to this cookbook example http://symfony.com/doc/current/cookbook/form/dynamic_form_generation.html#adding-an-event-subscriber-to-a-form-class The main difference
My code is below. I have an array, and by using this array I
I am using this code to pull my string array from my values folder:
I am using this code to check that array is present in the HashMap
I am using this PHP code: if (isset($_GET['c'])) { $pages = array(home, upload, signup);
I'm using this line of code to insert a value from an array into

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.