How can I parse JSON output in context of Jazz ANT build?
![]()
Arne Bister (2.6k●1●27●32)
| asked Feb 09 '14, 12:05 p.m.
JAZZ DEVELOPER edited Feb 09 '14, 4:26 p.m.
Jazzers,
on RTC 4.0.3 I was currently trying to do something to the JSON output of a cli command in my ANT build. I successfully ran the cli command in the context of an <exec> task, storing it in outputproperty="commandoutput" In a subsequent <script language="javascript"> task I can successfully do: <script language="javascript"> < ! [CDATA[ // writing this line with extra spaces to make it appear in jazz.net forum myjson = project.getProperty("commandoutput"); echo = project.createTask("echo"); echo.setMessage("Javascript found this:" + myjson); echo.perform(); ]]> </script> and the correct string output will appear in my build logs. But as soon as I added this line: var data = JSON.parse(myjson); the script task balked and threw this error in the build log: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "JSON" is not defined. (<Unknown source>#3) in <Unknown source> at line number 3 at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:156) [...] How can I parse JSON data in my ANT builds using the < script > task? What would I need to include for the javascript part to recognize JSON.parse() ? Thanks, Arne |