Ask Your Question

How do I create JSON output?

asked 2017-07-06 10:47:01 -0500

metadaddy gravatar image

I need to create a field that is JSON in my SDC pipeline. How do I do that?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-07-06 10:51:28 -0500

metadaddy gravatar image

You can do this in a Jython evaluator with json.dumps(). Just be sure to use record.value rather than plain record. You can also pass a field rather than the whole record:

import json

for record in records:
    # Whole record
    record.value['json'] = json.dumps(record.value)
    # Just a field
    record.value['json_address'] = json.dumps(record.value['address'])

  except Exception as e:
    # Send record to error
    error.write(record, str(e))

This results in output like: Jython Preview

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-07-06 10:47:01 -0500

Seen: 1,343 times

Last updated: Jul 06 '17