I have a collection called Platforms
in my backbone framework. The structure of this Platforms
collection is organized as follows:
Platforms
PlatformList
models
0: Platform
attributes
id: 1
name: "some name"
1: Platform
attributes
id: 2
name: "some other name"
My goal is to extract the attributes from each model within the collection and create a JSON array that looks like this:
[{"id":1,"name":"some name"},{"id":2,"name":"some other name"}]
When I tried using Platforms.models.toJSON()
or JSON.stringify(Platforms.models)
, I ended up with a literal string output of
"[[object Object], [object Object]]"
How can I generate the specific JSON array format that I require from this collection?