Your object misses a comma as shown below:

name: "Blue Stilton",
    age: "13"//comma is missing here
    smelly: true

JSON.stringify works fine as shown below.

var cheese_array = [
  {
    name: "Chedder",
    age: "34",
    smelly: true
  },
  {
    name: "Brie",
    age: "4",
    smelly: false
  },
  {
    name: "Blue Stilton",
    age: "13",
    smelly: true
  }
 ];
console.log(JSON.stringify(cheese_array))

However I am not sure how you get a log [object Object], [object Object], [object Object] I am presuming you are console logging something else please check that in your code.

Answer from Cyril Cherian on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › JSON › stringify
JSON.stringify() - JavaScript | MDN
If space is anything other than ... the given value, or undefined. ... A BigInt value is encountered. JSON.stringify() converts a value to the JSON notation that the value represents....
🌐
W3Schools
w3schools.com › js › js_json_stringify.asp
JSON.stringify()
JSON.stringify() can not only convert objects and arrays into JSON strings, it can convert any JavaScript value into a string.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-json-stringify-an-array-of-objects-in-javascript
How to JSON Stringify an Array of Objects in JavaScript ? - GeeksforGeeks
August 5, 2025 - In this approach, we're using JSON.stringify method with a replacer function to transform specific properties of objects during JSON serialization. Here, the replacer function checks if a property's value is a string and converts it to uppercase. ... Example: The below example uses JSON.stringify with a Replacer Function to JSON stringify an array of objects in JavaScript.
🌐
Reddit
reddit.com › r/learnjavascript › why does my array have "extra values". how can i json.stringify this info?
r/learnjavascript on Reddit: Why does my array have "extra values". How can I JSON.stringify this info?
November 29, 2021 -

This is weird but I am using a library that adds additional properties to array objects.

We have a simple array of numbers that looks like this:

[1,2,3,4,5,6]

This library I'm using (developed in house unfortunately) gives us the array but also adds extra props to it. When I console.log the array, what I actually see is:

[1,2,3,4,5,6, low: 1, high: 6, median: 3]

Unfortunately, JSON.stringify causes this info to get lost:

'[1,2,3,4,5,6]'

To make things more difficult, I do not know the exact properties that are "attached" to the array (sometimes its mean, sometimes its something completely domain specific).

How can I deal with these weird data types at runtime such that this info can be sent over the wire? Is it even possible? I imagine it breaks JSON schema of some sort.

Top answer
1 of 3
2
I'm not sure if it's helpful, but you could consider converting the array into an object of some sort so that you don't lose the properties. const arr = [1, 2, 3, 4, 5, 6]; arr.low = 1; arr.high = 6; arr.median = 3; const obj = {}; for (const key in arr) { obj[key] = arr[key]; } console.log(JSON.stringify(obj)); Or you might consider grouping the array together somehow (like if you at least know none of the added properties will be numbers): const arr = [1, 2, 3, 4, 5, 6]; arr.low = 1; arr.high = 6; arr.median = 3; const obj = { arr: [] }; for (const key in arr) { // probably should be more thorough in checking if the key is an integer here... if(!isNaN(key)) { obj.arr.push(arr[key]); continue; } obj[key] = arr[key]; } console.log(JSON.stringify(obj));
2 of 3
1
To add to what ashanev has said, here's some things that might be useful for your research: JSON.stringify() checks for a method called toJSON() , which you can use to create a serialized format for your special objects. If those are in-house, discuss if that would be a useful way forward. If you can't do that for whatever reason, Object.getOwnPropertyNames(obj) can list all the non-inherited properties on an object - even ones that don't show up in iterators like Object.keys(). You'll probably still need to determine what kind of special object it is so you can convert it to the right thing at the other end -- and keep this information updated (which is one reason for the above approach). JSON.parse() takes a reviver function to convert those custom serialized strings back in to the custom objects.
🌐
4D
developer.4d.com › 4d language › commands by theme › json › json stringify array
JSON Stringify array | 4D Docs
var $jsonObject : Object var $jsonString : Text QUERY([Company];[Company]Company Name="a@") OB SET($jsonObject;"company name";->[Company]Company Name) OB SET($jsonObject;"city";->[Company]City) OB SET($jsonObject;"date";[Company]Date_input) OB SET($jsonObject;"time";[Company]Time_input) ARRAY OBJECT($arraySel;0) While(Not(End selection([Company]))) $ref_value:=OB Copy($jsonObject;True) // If you do not copy them, the values will be empty strings APPEND TO ARRAY($arraySel;$ref_value) // Each element contains the selected values, for example: // $arraySel{1} = // {"company name":"APPLE","time":43200000,"city": // "Paris","date":"2012-08-02T00:00:00Z"} NEXT RECORD([Company]) End while $jsonString:=JSON Stringify array($arraySel) // $jsonString = "[{"company name":"APPLE","time":43200000,"city": //"Paris","date":"2012-08-02T00:00:00Z"},{"company name": //"ALMANZA",...}]"
🌐
ZetCode
zetcode.com › javascript › json-stringify
JavaScript JSON.stringify - Converting Objects to JSON
In this article we have converted JavaScript objects into JSON strings with the JSON.stringify function.
Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › JSON › parse
JSON.parse() - JavaScript | MDN
If the reviver only transforms some values and not others, be certain to return all untransformed values as-is — otherwise, they will be deleted from the resulting object. Similar to the replacer parameter of JSON.stringify(), for arrays and objects, reviver will be last called on the root value with an empty string as the key and the root object as the value.
🌐
HostingAdvice
hostingadvice.com › home › how-to
JavaScript "Object to String" Using JSON.stringify()
March 24, 2023 - Note: For the purposes of this article, whenever we say “object” we mean “object, array, or value.” We had it the other way around originally, but we quickly realized this became annoying to read. Let’s see some simple examples. Note that the whole string gets double quotes and all the data in the string gets escaped if needed. JSON.stringify("foo bar"); // ""foo bar"" JSON.stringify(["foo", "bar"]); // "["foo","bar"]" JSON.stringify({}); // '{}' JSON.stringify({'foo':true, 'baz':false}); // "{"foo":true,"baz":false}"
🌐
ReqBin
reqbin.com › code › javascript › wqoreoyp › javascript-json-stringify-example
How to stringify a JavaScript object to JSON string?
Note that a JSON object has several ... quotes; object property names are enclosed in double-quotes. The following is a syntax for the JSON.stringify() method: ... replacer (optional): a function that changes the behavior of the serialization process or an array of property names ...
🌐
DEV Community
dev.to › katherineh › jsonstringify-jsonparse-1585
JSON.stringify() & JSON.parse() - DEV Community
November 18, 2024 - JSON.stringify() converts JavaScript Objects an Arrays into JSON Strings.
🌐
ReqBin
reqbin.com › code › javascript › n2ek7onb › javascript-array-to-json-example
How do I convert JavaScript array to JSON?
JSON format came from JavaScript, ... for working with JSON data. ... The JSON.stringify(value, replacer, space) method in JavaScript converts arrays and objects to a JSON string....
🌐
Built In
builtin.com › software-engineering-perspectives › json-stringify
How to Use JSON.stringify() and JSON.parse() in JavaScript | Built In
// Note that only certain primitives will be deep copied when using JSON.parse() followed by JSON.stringify() const mySampleObject = { string: 'a string', number: 37, boolean: true, nullValue: null, notANumber: NaN, // NaN values will be lost (the value will be forced to 'null' in the serialized JSON string) dateObject: new Date('2019-12-31T23:59:59'), // Date will get stringified undefinedValue: undefined, // Undefined values will be completely lost, including the key containing the undefined value infinityValue: Infinity, // Infinity will be lost (the value will be forced to 'null' in the se
🌐
Adobe Experience League
experienceleaguecommunities.adobe.com › t5 › adobe-experience-manager › convert-stringified-array-of-objects-to-json-object › td-p › 606816
Solved: convert stringified array of objects to json objec... - Adobe Experience League Community - 606816
July 25, 2023 - hi this is more of a java based question but I could use some help here- i have a stringified (json.stringify) javascript array of strings ["abc","efg","ijk"] i want to convert it to a json object JsonObject jsonObject = new Gson().fromJson(arrayOfStrings, JsonObject.class); com.google.gson.Json...
🌐
ServiceNow Community
servicenow.com › community › developer-articles › interesting-facts-about-json-stringify › ta-p › 2329985
Interesting facts about JSON.stringify() - ServiceNow Community
June 5, 2021 - The object in which the key was found is provided as the replacer's this parameter. function replacer(key, value) { // Filtering out properties if (typeof value === 'string') { return undefined; } return value; } var foo = {foundation: 'Mozilla', model: 'box', week: 45, transport: 'car', month: 7}; JSON.stringify(foo, replacer); // '{"week":45,"month":7}' If replacer is an array, the array's values indicate the names of the properties in the object that should be included in the resulting JSON string.