fixed JSON serialization of TPersistent fields

When the object has a property referencing another object it must be
serialized as PtrInt instead of WriteObject, because it holds an ID
reference