title: Apache Beam - Reading JSON and Stream
body: <p>I am writing Apache beam code, where I have to read a JSON file which has placed in the project folder, and read the data and Stream it.</p>
  
  <p>This is the sample code to read JSON. Is this correct way of doing it?</p>
  
  <pre><code>PipelineOptions options = PipelineOptionsFactory.create();
  options.setRunner(SparkRunner.class);
  
  Pipeline p = Pipeline.create(options);
  
  PCollection&lt;String&gt; lines = p.apply("ReadMyFile", TextIO.read().from("/Users/xyz/eclipse-workspace/beam-prototype/test.json"));
  System.out.println("lines: " + lines);
  </code></pre>
  
  <p>or I should use,</p>
  
  <pre><code>p.apply(FileIO.match().filepattern("/Users/xyz/eclipse-workspace/beam-prototype/test.json"))
  </code></pre>
  
  <p>I just need to read the below json file. Read the complete <code>testdata</code> from this file and then Stream it.</p>
  
  <pre><code>{
  “testdata":{
  “siteOwner”:”xxx”,
  “siteInfo”:{
  “siteID”:”id_member",
  "siteplatform”:”web”,
  "siteType”:”soap”,
  "siteURL”:”www”,
  }
  }
  }
  </code></pre>
  
  <p>The above code is not reading the json file, it is printing like </p>
  
  <pre><code>lines: ReadMyFile/Read.out [PCollection]
  </code></pre>
  
  <p>, could you please guide me with sample reference?</p>