/// <summary> /// Content from s3 in format of /// ["val1", "val2", null, ...], /// ["val3", "val4", null, ...], /// ... /// To parse it as a json, we need to preappend '[' and append ']' to the stream /// </summary> /// <param name="content"></param> /// <param name="resultChunk"></param> private static void parseStreamIntoChunk(Stream content, SFResultChunk resultChunk) { Stream openBracket = new MemoryStream(Encoding.UTF8.GetBytes("[")); Stream closeBracket = new MemoryStream(Encoding.UTF8.GetBytes("]")); Stream concatStream = new ConcatenatedStream(new Stream[3] { openBracket, content, closeBracket }); IChunkParser parser = ChunkParserFactory.GetParser(concatStream); parser.ParseChunk(resultChunk); }
/// <summary> /// Content from s3 in format of /// ["val1", "val2", null, ...], /// ["val3", "val4", null, ...], /// ... /// To parse it as a json, we need to preappend '[' and append ']' to the stream /// </summary> /// <param name="content"></param> /// <param name="resultChunk"></param> private static void parseStreamIntoChunk(Stream content, SFResultChunk resultChunk) { Stream openBracket = new MemoryStream(Encoding.UTF8.GetBytes("[")); Stream closeBracket = new MemoryStream(Encoding.UTF8.GetBytes("]")); Stream concatStream = new ConcatenatedStream(new Stream[3] { openBracket, content, closeBracket }); // parse results row by row using (StreamReader sr = new StreamReader(concatStream)) using (JsonTextReader jr = new JsonTextReader(sr)) { resultChunk.rowSet = jsonSerializer.Deserialize <string[, ]>(jr); } }