title: A job module that writes JSON to file instead of XML
body: <p>I wrote a spring xd job module that exported from jdbc to xml. Several weeks ago. Was using Tuple as a data structure. Then using oxm to just write the Tuples to file. </p>
  
  <pre><code>&lt;bean id="xmlItemWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter" scope="step"&gt;
          &lt;property name="resource"
              value="file:${exportDir}/#{jobParameters['jobKey']}/#{stepExecutionContext['orderFileNamePrefix']}-#{stepExecutionContext['tableFileName']}.${exportFileExtension}" /&gt;
          &lt;property name="marshaller" ref="marshaller" /&gt;
          &lt;property name="rootTagName" value="#{stepExecutionContext['tableFileName']}" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="marshaller" class="org.springframework.oxm.xstream.XStreamMarshaller" scope="step"&gt;
          &lt;property name="aliases"&gt;
              &lt;util:map id="aliases"&gt;
                  &lt;entry key="#{stepExecutionContext['tableFileName']}" value="org.springframework.xd.tuple.batch.TupleFieldExtractor" /&gt;
              &lt;/util:map&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>The resulting xml was rather arbitrary. But there was no requirement for a specific xml schema. </p>
  
  <p>Now I'm doing the import part, using json instead of xml as a flat file format is a new requirement. So I'm looking for the smallest change I can make to the export module so it writes out json instead of xml. In spring xd it seems this sort of application would be better implemented using sources, streams and sinks. But I'm now stuck with a job module because the system that integrates the UI with spring xd sets up definitions automatically through the REST API.</p>
  
  <p>I would have thought working with Tuples and JSON would be pretty easy because of Spring's type conversion infrastructure. I just can't figure out how to implement in the spring xd job module context.</p>
  
  <p>So in a job module, what type of writer should I use to write lists of Tuples to file using json as a format?
  What reader should I use to read json files to lists of Tuples?</p>
  
  <p>I'll admit there is much of spring xd I don't fully understand. Some direction would be much appreciated.</p>