-Added JSON Schema implementation
-Move test serialization objects to TestObjects namespace -Fixed JsonConvert to always write a floating point number with a decimal place -Changed Type values to serialize and deserialize to type name string -Fixed JsonWriter to allow objects and arrays to be written in a constructor -Added JsonContainerAttribute with Id, Title and Description members. JsonObject and JsonArray inherit from this attribute -Added JsonArrayAttribute. Has flag to control whether array can contain null items. -Added IsRequired to JsonProperty -Replaced protected method GetSerializableMembers with GetMemberMappings on JsonSerializer -Fixed QuoteChar not getting set when parsing property name -Added Load(JsonReader) to JProperty, JConstructor -Fixed error when populating JProperty with content from collection -Added the ability for JsonTokenWriter to write individual values as well as arrays and objects -Added CreateReader to JToken -Added FromObject to JToken -Added ReadFrom to JToken
This commit is contained in:
@@ -160,5 +160,33 @@ namespace Newtonsoft.Json.Linq
|
||||
{
|
||||
return _name.GetHashCode() ^ ContentsHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads an <see cref="JConstructor"/> from a <see cref="JsonReader"/>.
|
||||
/// </summary>
|
||||
/// <param name="reader">A <see cref="JsonReader"/> that will be read for the content of the <see cref="JConstructor"/>.</param>
|
||||
/// <returns>A <see cref="JConstructor"/> that contains the JSON that was read from the specified <see cref="JsonReader"/>.</returns>
|
||||
public static JConstructor Load(JsonReader reader)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.None)
|
||||
{
|
||||
if (!reader.Read())
|
||||
throw new Exception("Error reading JConstructor from JsonReader.");
|
||||
}
|
||||
|
||||
if (reader.TokenType != JsonToken.StartConstructor)
|
||||
throw new Exception(
|
||||
"Error reading JConstructor from JsonReader. Current JsonReader item is not a constructor: {0}".FormatWith(
|
||||
CultureInfo.InvariantCulture, reader.TokenType));
|
||||
|
||||
JConstructor c = new JConstructor((string)reader.Value);
|
||||
|
||||
if (!reader.Read())
|
||||
throw new Exception("Error reading JConstructor from JsonReader.");
|
||||
|
||||
c.ReadContentFrom(reader);
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user