Hi,
I’m trying to create a collection like this:
{ “fps”: 30, “date”: {{now}} }
I’ve been trying to figure out how to make an expression that can do it without using an extra operation and module like parse JSON. toCollection seems like it might work, but try as I might I can’t figure it out.
Thanks!
Hey there,
what do you need this collection for? For the most part, you can type it in just like that directly inside the module you need it for. No need to transform it first.
I have a data store where each record has an array of collections. The collections have a pair of keys, one of which is a value (fps) and the other is the date when the value was sampled. There are a very large number of records and so I’m trying to keep ops to a minimum and avoid even one extra module if I can.
the records look like:
{ …
fps_history: [ { fps: 15, date: “some date” }, { fps: 10, date: “another date” }, .. ],
avg_fps_history: [ { avg_fps: 15, date: “some date” }, { avg_fps: 12, date: “another date” } ]
…
}
So I’m basically trying to add a new pair to fps_history (and avg_fps_history). It’s easy to do for a simple array with add(simple_fps_array; newFps) but since this is an array of collections I essentially want do add(fps_history, { “fps”: 20; “date”: “{{now}}” })
Dave
So you want to add a collection to an array of collections? Here or here.
Both of those use parse JSON which I know how to do but want to avoid the extra module/Op. When you have a few million records the costs add up of extra steps.
Yeah you should be able to type in the same thing directly. Like here for example. They are using the JSON module to make it easier to manage, but yo should be able to type in the JSON structure inside the add() function directly and save on that operaion.
nooo… you cannot use JSON in an add function. It does not perform the parsing of JSON string to an object (Make collection variable) for you.
Hope this helps! Let me know if there are any further questions or issues.
— @samliew
P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.
That didn’t work. I’d tried it before.
The operation failed with an error. Failed to map ‘data.fps_changes’: Function ‘add’ finished with error! Function ‘toArray’ finished with error! ‘{“fps”: “99”’ is not a valid collection.
Technically all we need is a built-in parseJSON
function.
I’m sure others would agree that this is a nice feature to have.
You can submit this suggestion to the Idea exchange, under Platform Ideas and Improvements
Don’t forget to search for it first, just in case someone already suggested it, so that you don’t end up creating a duplicate.

Hope this helps! Let me know if there are any further questions or issues.
— @samliew
P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.
For some reason all semicolons are getting recognized and made parts of the formula. So the second semicolon is breaking it. You need to escape it and have a standard semicolon there instead of the one which is part of the formula.