cancel
Showing results for 
Search instead for 
Did you mean: 

Json Construct in Alfresco JavaScript

pmrreddy
Champ on-the-rise
Champ on-the-rise
Hi All,

I need help to find a way to write data in json format in Alfresco Javascript.

I know we have jsonUtils object in alfresco that can generate a json from Javascript Native object through jsonUtils.toJsonString() method, the object only available in Webscripts only.

I need to write a script in Alfresco the script will be in Data Dictionary / Scripts location, from there when the script executes that need to generate a output file in the same location that contain data in Json format, I have the data with me that need to generate in Json format, i cannot use that method jsonUtils.toJsonString() because its not a webscript.

please help to slove the issue.

Regards.
pmr
2 REPLIES 2

mitpatoliya
Star Collaborator
Star Collaborator
Well you can always use javascripts functions which could do this for you.
http://www.w3schools.com/json/json_eval.asp
http://stackoverflow.com/questions/16507222/create-json-object-dynamically-via-javascript-without-co...
Also untlimatly if you see jsonUtils of Alfresco they have create those APIs on top of basic javascript functions only.So even you can raplicate that in your javascript file.

Hi mitpatoliya,

Thanks for you reply, the first link you gave for json eval that will parse the json string into javascript native object, but i need to construct a json string from my javascript native object and write the same json string in to a node. If i am wrong please give a example so that i can go through that.

Thankyou
Param