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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:24:11+00:00 2026-06-13T12:24:11+00:00

Im having some issues when trying to get some Json data into a specific

  • 0

Im having some issues when trying to get some Json data into a specific format.

I basically need this Json data:

{
query: [ ],
products: 
[

{
title: "title 1",
price: "6.00",
magazine: "magazine name 1",
image: "/p/c/pc_90_cover.jpg",
type: "Magazine",
market: "Technology",
zinio: "http:www.zinio.com",
newsstand: "http://www.link1.php"
},


{
title: "title 2",
price: "6.00",
magazine: "magazine name 2",
image: "/p/c/pc_90_cover.jpg",
type: "Magazine",
market: "Technology",
zinio: "http:www.zinio.com",
newsstand: "http://www.link2.php"
},


{
title: "title 3",
price: "6.00",
magazine: "magazine name 3",
image: "/p/c/pc_90_cover.jpg",
type: "Magazine",
market: "Technology",
zinio: "http:www.zinio.com",
newsstand: "http://www.link3.php"
}
]

To go into this javascript array:

var arrProducts = [
                          title:  "{{ product.title }}",
                          url:  "{{ product.url }}",
                          label:  "{{ product.title }}",
                          magazine: "{{ product.magazine }}",
                          image: "{{ product.imageThumb }}",
                          newsstand: "{{ product.newsstand }}",
                          kindle: "{{ product.kindle }}",
                          barnesnoble: "{{ product.barnesnoble }}",
                          zinio: "{{ product.zinio }}",
                          kobo: "{{ product.kobo }}",
                          waterstones: "{{ product.waterstones }}",
                          type: "{{ product.type }}",
                      },
             ];

I have tried using:

var allProducts = $.get("http://localhost:8888/web/app_dev.php/api/v1/search/search.json, function(data) {

var productsArray = data.products; 

console.log(productsArray);

});

But that method does not build the array in the format I require. Console.log outputs a bunch of objects. Maybe an for each loop could be a solution? – Any help is appreciated, my Javascript isnt that great!

  • 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-06-13T12:24:12+00:00Added an answer on June 13, 2026 at 12:24 pm

    use http://jsonlint.com to validate your json. If it won’t pass there, it won’t pass through ajax either. Your sample is missing double quotes on object keys and a starting brace and has extra comma and your file shoudn’t include var arrProducts = when consumed by ajax

    There is a difference however if you place a script tag with this file in page during initial page load. Then the var arrProducts = is needed and the quotes on object keys are not. Then rather than ajax you would simply loop over the variable arrProducts

    EDit:

    To loop over first sample

    $.getJSON( url, function(data) { 
        var productsArray = data.products;  
        $.each(  productsArray, function( i, item){ 
    
             console.log( 'Title is '+ item.title)
    
        })
    
    })
    

    There is a wealth of information available about how to parse json and loop over objects and arrays … did you try searching?

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

Sidebar

Related Questions

I'm having some issues to deserialize a Json array that follows this format: [
I'm having some major issues trying to grab all the data I need for
I am trying to get php's namespace technique down but having some issues here:
I'm trying to get started with twitter4r but I'm having some issues: Why I
I'm trying to convert some VB.net code into C# and having issues trying to
Hey guys and gals I'm having some major issues trying to get my application
All, I'm trying to get my positioning set up and I'm having some issues
I am having some issues trying to get my automated builds to compile projects
Hi I am having some issues trying to get check box values. For a
I am trying to get facebook wall but I am having issues with JSON

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.