def to_json(self, indent=None):
inputs = ParameterCollection(self.inputs)<EOL>d = {<EOL>'<STR_LIT>': {<EOL>'<STR_LIT:name>': self.name,<EOL>'<STR_LIT:description>': self.description<EOL>},<EOL>'<STR_LIT>': [],<EOL>'<STR_LIT>': [],<EOL>'<STR_LIT>': [{'<STR_LIT:name>': k, '<STR_LIT>': v} for k, v in six.iteritems(self.output_mapping)]<EOL>}<EOL>for parameter in self.inputs:<EOL><INDENT>input_info = {<EOL>'<STR_LIT:name>': parameter.name,<EOL>'<STR_LIT:type>': parameter.id<EOL>}<EOL>args, kwargs = parameter.serialize_args()<EOL>args = list(args)<EOL>args.pop(<NUM_LIT:0>)  <EOL>kwargs.pop('<STR_LIT>', None)  <EOL>if args or kwargs:<EOL><INDENT>input_info['<STR_LIT:args>'] = [args, kwargs]<EOL><DEDENT>d['<STR_LIT>'].append(input_info)<EOL><DEDENT>for node in sorted(six.itervalues(self.nodes_by_id), key=lambda x: x.id):<EOL><INDENT>task_name = node.task.name<EOL>if not task_name:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(<EOL>node.task.__class__.__name__)<EOL>)<EOL><DEDENT>node_inputs = {}<EOL>for input_name, (source, value) in six.iteritems(node.inputs):<EOL><INDENT>input_info = {'<STR_LIT:source>': source}<EOL>if source == '<STR_LIT:input>':<EOL><INDENT>input_info['<STR_LIT:input>'] = inputs.by_name[value].name<EOL><DEDENT>else:<EOL><INDENT>input_info['<STR_LIT>'] = value<EOL><DEDENT>node_inputs[input_name] = input_info<EOL><DEDENT>d['<STR_LIT>'].append({<EOL>'<STR_LIT:id>': node.id,<EOL>'<STR_LIT>': task_name,<EOL>'<STR_LIT>': node_inputs<EOL>})<EOL><DEDENT>return json.dumps(d, indent=indent)<EOL>
Serialize this workflow to JSON