private JToken CreateJObject(JsonReader reader) { ValidationUtils.ArgumentNotNull(reader, "reader"); // this is needed because we've already read inside the object, looking for special properties JToken token; using (JTokenWriter writer = new JTokenWriter()) { writer.WriteStartObject(); if (reader.TokenType == JsonToken.PropertyName) writer.WriteToken(reader, reader.Depth - 1); else writer.WriteEndObject(); token = writer.Token; } return token; }
private JToken CreateJToken(JsonReader reader, JsonContract contract) { ValidationUtils.ArgumentNotNull(reader, "reader"); if (contract != null && contract.UnderlyingType == typeof(JRaw)) { return JRaw.Create(reader); } else { JToken token; using (JTokenWriter writer = new JTokenWriter()) { writer.WriteToken(reader); token = writer.Token; } return token; } }