.. _json-tags:
=========
JSON TAGS
=========
tags:
#.
output: {}
#.
output: "test": {}
#.
output: "test": "String value from ValueStack"
#.
output: "test": "Number value from ValueStack"
#.
output: "valuefromvaluestack"
#.
output: []
#.
output: "listName": []
#. "test"
output: var name = "test" ;
example:
--------
.. code-block:: html
<%@taglib prefix="j" tagdir="/WEB-INF/tags/json"%>
output:
^^^^^^^^
.. code-block:: json
{
"error": {
"type": "...",
"message": "...",
"stackTrace": [
{
"className": "...",
"method": "...",
"line": "..."
},
{ ... }
]
}
}
example:
--------
.. code-block:: html
output:
^^^^^^^^
.. code-block:: javascript
var data = {
"fileId" : "...",
"fileName": "...",
"fileSizeName": "...",
"contentType": "..."
}
.. note:: [IMPORTANT!]
| If request.setAttribute is used, is required the use of '#request.' to retrieve the object in the request.
| If the object to retrieve is a property of an action it can be referenced by name without any other alias.
| If the object to retrieve is put in the ValueStack it can be referenced by name without any other alias.
------------------
Action:
::
...
request.setAttribute("list", list);
ActionContext.getContext().getValueStack().set("list2", list2);
------------------
JSP:
::
...
.. note:: [NOTE] if this exception is thrown: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String change [