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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:17:23+00:00 2026-05-31T16:17:23+00:00

Here is my response code in jQuery: var response = $.parseJSON(response); for (var i

  • 0

Here is my response code in jQuery:

var response = $.parseJSON(response);

for (var i = 0; i < response.groupIds.length; i++) {
    console.log(response.groupIds[i], i);
}

Each response.groupIds[i] is of the form {"unknown name":"unknown value"}.

I wish to access both of these bits of data in javascript, how do I accomplish this when I don’t know in advance what e.g. unknown name is?

  • 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-31T16:17:25+00:00Added an answer on May 31, 2026 at 4:17 pm

    Use Object.keys to retrieve a full list (array) of key names. A polyfill is available here.

    var group = response.groupIds[i];
    
    var allPropertyNames = Object.keys(group);
    for (var j=0; j<allPropertyNames.length; j++) {
        var name = allPropertyNames[j];
        var value = group[name];
        // Do something
    }
    

    Your question’s response format contains only one key-value pair. The code can then be reduced to:

    var group = response.groupIds[i];
    var name = Object.keys(group)[0]; // Get the first item of the list;  = key name
    var value = group[name];
    

    If you’re not interested in the list, use a for-i-in loop with hasOwnProperty. The last method has to be used, to exclude properties which are inherit from the prototype.

    for (var name in group) {
        if (group.hasOwnProperty(name)) {
            var value = group[name];
            // Do something
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here's my code with jquery: function check_hotel_exists(value, col) { var url = base_url +
I have this jquery code: var response = $(div.callbacktwo).html(result); if (response == 'Added!'){ //some
I have a login form using jquery ajax and a php code. The issue
I have jQuery code that adds a response to the last <tr> of a
I've successfully installed this jQuery-based signup form here: http://net.tutsplus.com/tutorials/javascript-ajax/building-a-sleek-ajax-signup-form/ But when I applied it
I have the following jQuery code: $('.save').submit(function(e){ var formElement = $(this); var data =
I'm using jquery and the jquery-json plugin found here: http://code.google.com/p/jquery-json/ I've checked at http://jsonlint.com/
Here is my code in my jquery/javascript that is performing the ajax request... else
I saw a code snippet yesterday in one of the responses here on StackOverflow
Here is my response envelope: <s:Envelope xmlns:s=http://schemas.xmlsoap.org/soap/envelope/> <s:Body> <s:Fault> <faultcode>s:Client</faultcode> <faultstring xml:lang=en-US>The creator of

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.