// serializes an array property private void _serializeArray(BplProperty property, ICollection values, IBplJsonConverter itemConverter) { _output.Indent("["); int i = 0, N = values.Count; foreach (var value in values) { _output.BeginClause(null); _serializeScalar(property, value, itemConverter); _output.EndClause(i == N - 1); i++; } _output.Outdent("]"); }
// serializes a scalar property private void _serializeScalar(BplProperty property, object value, IBplJsonConverter converter) { string literal = null; if (property.IsWeakAssociation) { var weakId = ((BplIdentity)value).ToString(property.ReferencedClass.IdentityScope); if (weakId.NotEmpty()) literal = Quote(weakId); } else { literal = converter.Format(value); } if (literal.NotEmpty()) { _output.Append(literal); } else { _output.Append("null"); } }