[magnolia-dev] [JIRA] (JSMODELS-5) Way to get the JS data structure of an argument

"JIRA (on behalf of Christopher Zimmermann)" <jira-O8DnXSz/[email protected]>
Newsgroups gmane.comp.cms.magnolia.devel
Message-ID <[email protected]>
Christopher Zimmermann created an issue

Magnolia Javascript Models / https://jira.magnolia-cms.com/browse/JSMODELS-5 JSMODELS-5

Way to get the JS data structure of an argument

Issue Type:
Task

Assignee:
Jaroslav Simak

Created:
16/May/17 4:28 PM

Priority:
Neutral

Reporter:
Christopher Zimmermann

It's difficult to work with the objects that are passed into the methods of a JS model from the templating script, because its hard to know the structure of the object.

For example the object returned by cmsfn.children is an object of objects, so it cannot be iterated as a javascript array.

If you return an array from a model, then pass that array to another model function.

- It cannot be iterated with for(var item in input) {

- It cannot be iterated with or each (item in input){

- it does not have a length.

It would be useful if the developer could determine its structure.
-
Maybe there should be method which outputs a string representation of the data structure. I tried using JSON.stringify, but it always returns undefined.
http://codereview.stackexchange.com/questions/91184/java-json-stringifier-with-the-nashorn-api
http://mail.openjdk.java.net/pipermail/nashorn-dev/2013-September/002012.html
-
If there is an existing method in Java or JS that solves this problem, then we should simply document that.

https://jira.magnolia-cms.com/browse/JSMODELS-5#add-comment
Add Comment

This message was sent by Atlassian JIRA (v7.2.6#72008-sha1:26175bf)

----------

----------------------------------------------------------------

For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html

Alternatively, use our forums: http://forum.magnolia-cms.com/

To unsubscribe, E-mail to: <[email protected]>

----------------------------------------------------------------
(unnamed) (image/gif, 98 B) - not displayed
(unnamed) (image/png, 1.1 KB) - not displayed
(unnamed) (image/png, 468 B) - not displayed
(unnamed) (image/png, 2.9 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.