Skip to content

Commit

Permalink
Changed Json Extractor to streaming read into reading all into memory…
Browse files Browse the repository at this point in the history
… at once.
  • Loading branch information
steventmayer committed Sep 22, 2016
1 parent 03405b3 commit 79f1758
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,16 @@ public override IEnumerable<IRow> Extract(IUnstructuredReader input, IUpda
// Json.Net
using(var reader = new JsonTextReader(new StreamReader(input.BaseStream)))
{
// Parse Json
// TODO: Json.Net fails with empty input files
var root = JToken.ReadFrom(reader);

// Rows
// All objects are represented as rows
foreach(JObject o in SelectChildren(root, this.rowpath))
// Parse Json one token at a time
while (reader.Read())
{
// All fields are represented as columns
this.JObjectToRow(o, output);
if (reader.TokenType == JsonToken.StartObject)
{
var token = JObject.Load(reader);
this.JObjectToRow(token, output);

yield return output.AsReadOnly();
yield return output.AsReadOnly();
}
}
}
}
Expand Down

0 comments on commit 79f1758

Please sign in to comment.