how to create json array in javascript?

how to create json array in javascript – Arrays in JSON are almost the same as arrays in JavaScript. In JavaScript, you can use JSON.stringify to convert an array or values into a JSON formatted string.

how to create json array in javascript

The first method will use for loop for creating JSON array from an input array. Syntax of Arrays in JSON Objects: JSON is JavaScript Object Notation is used for data interchange, Array of strings is an ordered list of values with string type.

create json array in javascript

json example array

	"mobiles":[ "Oppo", "Nokia", "Moto" ]

// Another exemple
    "people": [
            "website": "",
            "from": "USA",
            "name": "Bhavika"
            "website": "",
            "from": "PK",
            "name": "Ummides"

js create json array

var members = {
    accounting: []

for(var i in companyDetails) {    

    var item = companyDetails[i];   

        "MemberUserName" : item.MemberUserName,
        "memberSirname"  : item.memberSirname,
        "age"       : item.age 

json arrays

  "array": [{1,2,3,4,5,6}]

Don’t Miss : json to array php

javascript create json object from array

var array = ['a', 1, 'b', 2, 'c', 3],
    object = {},

for (var i = 0; i < array.length; i += 2) {
    object[array[i]] = array[i + 1];


Hwo to access arary in json


I hope you get an idea about how to create json array in javascript.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment