I am trying to pass a Javascript function as the JSONObject element in primefaces.
In my Java backing bean, I have:
JSONObject serie = new JSONObject();
serie.put("name", "Single data serie");
...
serie.put( <other JSON fields and objects> )
...
serie.put("method", "function() { return '1'; }");
Then I send the object serie to frontend and use that JSONObject in my Javascript. Everyting works fine, except that "method" is being considered as String, not as function.
Is there any way to send the function as function, not String?
I use the
org.primefaces.json.JSONObject
class. I know, that there is also the class
org.json.JSONObject
but it seems to me as the same.
Regards,
Mateusz