What error do you get when you try to import the “json” lib? The Script snap uses Jython 2.7.2 which seems to support json, however, I’m not so sure about numpy.
I was able to add “import json” to your script, and could then parse the json string with json.dumps(). Similarly, I could convert dict to a json string with json.dumps (ie, json.dumps(py_dict)).
def execute(self):
while self.input.hasNext():
data = self.input.next()
url = "https://gorest.co.in/public-api/products"
get = GetMethod(url)
client = HttpClient()
r = client.executeMethod(get)
s = get.getResponseBodyAsString()
py_dict = json.loads(s)
t = get.getStatusText()
h = get.getResponseHeaders()
self.output.write(py_dict)
self.log.info("Finished executing the upload script")
For numpy, I assume you are getting an import error? Jython 2.7.2 seems to offer some support for this library, and uses Jython Native Interface (JyNI) to access the Numpy c library. I’m less familiar with our Python scripting support and would need to investigate this.