public override void WriteJson(JsonWriter writer, SharedVariable value, JsonSerializer serializer) { var obj = new JObject { { "Type", NodeSerializer.EvaluateType(value.GetType()) }, }; if (value.IsGlobal) { obj.Add("IsGlobal", true); obj.Add("IsShared", true); if (!string.IsNullOrEmpty(value.Name)) { obj.Add("Name", value.Name); } } else if (value.IsShared) { if (!string.IsNullOrEmpty(value.Name) && value.Name != "None") { obj.Add("Name", value.Name); obj.Add("IsShared", true); } else { WriteValue(obj, value, serializer); } } else { WriteValue(obj, value, serializer); } obj.WriteTo(writer); }