{
public class JsonObject : JsonValue, IDictionary<string, JsonValue>, ICollection<JsonPair>
{
- Dictionary<string, JsonValue> map;
+ // Use SortedDictionary to make result of ToString() deterministic
+ SortedDictionary<string, JsonValue> map;
public JsonObject (params JsonPair [] items)
{
- map = new Dictionary<string, JsonValue> ();
+ map = new SortedDictionary<string, JsonValue> (StringComparer.Ordinal);
if (items != null)
AddRange (items);
if (items == null)
throw new ArgumentNullException ("items");
- map = new Dictionary<string, JsonValue> ();
+ map = new SortedDictionary<string, JsonValue> (StringComparer.Ordinal);
AddRange (items);
}
stream.WriteByte ((byte) '"');
stream.WriteByte ((byte) ',');
stream.WriteByte ((byte) ' ');
- pair.Value.Save (stream);
+ if (pair.Value == null) {
+ stream.WriteByte ((byte) 'n');
+ stream.WriteByte ((byte) 'u');
+ stream.WriteByte ((byte) 'l');
+ stream.WriteByte ((byte) 'l');
+ } else
+ pair.Value.Save (stream);
}
stream.WriteByte ((byte) '}');
}