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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:51:07+00:00 2026-05-22T19:51:07+00:00

I’m having some problems with converting some JSON and I’m after some help. This

  • 0

I’m having some problems with converting some JSON and I’m after some help. This is my problem, I have JSON returned the following:

Example of the JSON recieved (from a CSV file):

[
    {
        "rating": "0",
        "title": "The Killing Kind",
        "author": "John Connolly",
        "type": "Book",
        "asin": "0340771224",
        "tags": "",
        "review": "i still haven't had time to read this one..."
    },
    {
        "rating": "0",
        "title": "The Third Secret",
        "author": "Steve Berry",
        "type": "Book",
        "asin": "0340899263",
        "tags": "",
        "review": "need to find time to read this book"
    },

    cut for brevity   

]

Now, this is a one dimensional array of objects, but I have a function that I need to pass this to that will ONLY take a multidimensional array. There’s nothing I can change on this. I’ve been looking around the web for conversion and came across this code:

if (! obj.length) { return [];} // length must be set on the object, or it is not iterable  
   var a = [];  

   try {  
       a = Array.prototype.slice.call(obj, n);  
   }  
   // IE 6 and posssibly other browsers will throw an exception, so catch it and use brute force  
   catch(e) {  
       Core.batch(obj, function(o, i) {  
           if (n <= i) {  
               a[i - n] = o;  
           }  
       });  
   }  

   return a;  

But my code keeps getting stuck on the “no object length” part. When I iterate through each object, I get character by character. Unfortunately, those field names (rating, title, author), etc are not set in stone and I can’t access anything using the obj.Field notation.

I’m stuck on this; is there a way to convert those objects into arrays, or do I have to go back to the beginning and dump JSON?

  • 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-22T19:51:08+00:00Added an answer on May 22, 2026 at 7:51 pm

    There is a nice JavaScript library called Undersore.js which does all kind of object/array manipulations.

    Using it you could do the conversion as easy as this

    _(json).each(function(elem, key){
        json[key] = _(elem).values();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.