From 1e84e47455191f75334f29a71a5468196cfb1181 Mon Sep 17 00:00:00 2001 From: scymen Date: Tue, 6 Jan 2015 14:00:56 +0800 Subject: [PATCH] 1.fixed error when reflecting an indexed property(ignore it). 2.continue to reflect next object instead of throwing an exception when _current_deption > _MAX_DEPTH. --- fastJSON/JsonSerializer.cs | 8 ++++++-- fastJSON/Reflection.cs | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fastJSON/JsonSerializer.cs b/fastJSON/JsonSerializer.cs index 78d902b..b9f72c5 100644 --- a/fastJSON/JsonSerializer.cs +++ b/fastJSON/JsonSerializer.cs @@ -364,8 +364,12 @@ private void WriteObject(object obj) _TypesWritten = true; _current_depth++; if (_current_depth > _MAX_DEPTH) - throw new Exception("Serializer encountered maximum depth of " + _MAX_DEPTH); - + { + //throw new Exception("Serializer encountered maximum depth of " + _MAX_DEPTH); + _output.Append('}'); + _current_depth--; + return; + } Dictionary map = new Dictionary(); Type t = obj.GetType(); diff --git a/fastJSON/Reflection.cs b/fastJSON/Reflection.cs index c390bab..d40a015 100644 --- a/fastJSON/Reflection.cs +++ b/fastJSON/Reflection.cs @@ -481,6 +481,10 @@ internal Getters[] GetGetters(Type type, JSONParameters param) List getters = new List(); foreach (PropertyInfo p in props) { + if (p.GetIndexParameters().Length > 0) + {// Property is an indexer + continue; + } if (!p.CanWrite && param.ShowReadOnlyProperties == false) continue; if (param.IgnoreAttributes != null) {