I have been working on STAF & STAX. My objective is to read a JSON file using STAF & STAX Return Testcase PASS or FAIL. I tried updating my staf to latest version with latest python version.
Python Version Detail
20130408-15:38:19
Python Version : 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)]
Here is my Code:
try:
import simplejson as json
except ImportError:
import json
title = []
album = []
slist = []
json_data=open('d:\Json_File.txt')
data = json.load(json_data)
for i in range(data["result"].__len__()):
title = data["result"][i]["Title"]
album = data["result"][i]["Album"]
slist = data["result"][i]["Title"] + ' [' + data["result"][i]["Album"] + '] \n'
It is giving error given below
20130408-11:32:26 STAXPythonEvaluationError signal raised. Terminating job.
===== XML Information =====
File: new13.xml, Machine: local://local
Line 15: Error in element type "script".
===== Python Error Information =====
com.ibm.staf.service.stax.STAXPythonEvaluationException:
Traceback (most recent call last):
File "<pyExec string>", line 1, in <module>
ImportError: No module named simplejson
===== Call Stack for STAX Thread 1 =====[
function: main (Line: 7, File: C:\STAF\services\stax\samples\new13.xml, Machine: local://local)
sequence: 1/2 (Line: 14, File: C:\STAF\services\stax\samples\new13.xml, Machine: local://local)
]
What's the process to include JSON in STAF Module.