public void JsonLeaf(string propertyName, string value, bool isQuoted) { if (objectTypePending) { bool isTypeSpecifierLeaf = false; Type attributeTypeHint = null; if (propertyName.Equals(TypeSpecifier)) { attributeTypeHint = TypeAntiAliaser(value); isTypeSpecifierLeaf = true; } else { attributeTypeHint = inferCurrentTypeFromStack(false); } if (attributeTypeHint == null) { string message = String.Format("cant load type: \"{0}\" in json:{1}", value, json); NoClueForTypeException ex = new NoClueForTypeException(message); throw ex; } object newObject = newInstance(attributeTypeHint); ObjectFrame objectHolder = (ObjectFrame)objects.Peek(); objectHolder.theObject = newObject; listener.onCreateObject(newObject); objectTypePending = false; if (isTypeSpecifierLeaf) { return; } } if (objectTypePending || objects.Count == 0) { string message = string.Format("unable to set property {0} with value {1} because type is not found yet ", propertyName, value); throw new Exception(message); } string strError = null; if (TypeSpecifier != null && propertyName != null && propertyName.Equals(TypeSpecifier)) { // todo raise a warning here or throw an exception in strict mode } else { objects.Peek().submitLeafToStack(propertyName, value, setValueinObject, listener); } if (strError != null) { throw new Exception(strError); } }
public void JsonLeaf(string propertyName, string value, bool isQuoted) { if (objectTypePending) { bool isTypeSpecifierLeaf = false; Type attributeTypeHint = null; if (propertyName.Equals(TypeSpecifier)) { attributeTypeHint = TypeAntiAliaser(value); isTypeSpecifierLeaf = true; } else { attributeTypeHint = inferCurrentTypeFromStack(false); } if (attributeTypeHint == null) { string message = String.Format("cant load type: \"{0}\" in json:{1}", value, json); NoClueForTypeException ex = new NoClueForTypeException(message); throw ex; } object newObject = newInstance(attributeTypeHint); ObjectFrame objectHolder = (ObjectFrame)objects.Peek(); objectHolder.theObject = newObject; listener.onCreateObject(newObject); objectTypePending = false; if (isTypeSpecifierLeaf) return; } if (objectTypePending || objects.Count == 0) { string message = string.Format("unable to set property {0} with value {1} because type is not found yet ", propertyName, value); throw new Exception(message); } string strError = null; if (TypeSpecifier != null && propertyName != null && propertyName.Equals(TypeSpecifier)) { // todo raise a warning here or throw an exception in strict mode } else { objects.Peek().submitLeafToStack(propertyName, value, setValueinObject, listener); } if (strError != null) throw new Exception(strError); }