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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:34:47+00:00 2026-06-14T15:34:47+00:00

Ok, this question may be dumb, but I’m really stuck with this. I want

  • 0

Ok, this question may be dumb, but I’m really stuck with this.

I want to a json structure like the following:

order: {
    currency: 'eur',
    order_items: [
        {
            id: 3,
            quantity: 1
        },
        {
            id: 67,
            quantity: 1
        }
    ]
}

What I’m doing right now is this:

function makeOrder(){
    var myArray = new Array();
    for(var i=0;i<bookedItemsArray.length;i++){
        var newObject = new OrderedItem(bookedItemsArray[i].id, bookedItemsArray[i].amount);
        myArray.push(newObject);
    }
    var mystring = JSON.stringify(myArray);
    //myString = "order: {currency: 'eur', order_items: " + myString + "}";
    console.log(myString);​
}

The way I get the data inside the order_items array is being cool, but when I try to concat the array with the rest (line in comments), I get:

?:??: W/?(?): Uncaught SyntaxError: Unexpected token ILLEGAL at file:///android_asset/www/november/js/t03/Booking/bookingProcess.js:96

Is there something I’m missing about the way a string and a JSON structure can be combined?

Thank you very much.

  • 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-14T15:34:48+00:00Added an answer on June 14, 2026 at 3:34 pm

    why don’t you do it like this?

    var x = {
        order: {
            currency: 'eur',
            order_items: []
        }
    };
    for (var i = 0; i < 10; i++) {
        var newObject = {
            i: i,
            Text: 'Some Text'
        };
        x.order.order_items.push(newObject);
    }
    
    var str = JSON.stringify(x);
    

    look at this fiddle: http://jsfiddle.net/9V6Vb/

    Here is the generated JSON:

    {
        "order": {
            "currency": "eur",
            "order_items": [{
                "i": 0,
                "Text": "Some Text"},
            {
                "i": 1,
                "Text": "Some Text"},
            {
                "i": 2,
                "Text": "Some Text"},
            {
                "i": 3,
                "Text": "Some Text"},
            {
                "i": 4,
                "Text": "Some Text"},
            {
                "i": 5,
                "Text": "Some Text"},
            {
                "i": 6,
                "Text": "Some Text"},
            {
                "i": 7,
                "Text": "Some Text"},
            {
                "i": 8,
                "Text": "Some Text"},
            {
                "i": 9,
                "Text": "Some Text"}]
        }
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a really dumb question but I'm just starting to learn the
im really new to linq-to-SQL so this may sound like a really dumb question,
This may seem like a dumb question, but can an app build with c#
This may be a dumb question but it seems like activateIgnoringOtherApps: may be the
This may seem like a dumb question but I have IDLE and I'm trying
This may be a dumb question, but I really have no idea and I'm
This may sound like a dumb question, but is one APNS certificate good for
I know this may sound like a dumb question but I got to know
This may sound like a bit of a dumb question but how do I
This may seem like a dumb question but I don't know how to do

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.