Is Object, a MemberDef or a Schema?
Last updated
Last updated
An object can be represented as a MemberDef or a Schema. Object as a MemberDef can be easily differentiated from Object as a schema using some rules expressed in the flowchart below.
If the first value in the object is a string and valid datatype such as number, string, object, bool, etc. then the object is a MemberDef. In the following example, the name
is a MemberDef, because it defines the string value.
If the object has a type member then it is parsed as MemberDef. In the following example, testScore
is a MemberDef, as it defines the type of object.
If the object contains schema then it is a MemberDef. In the following example, testData
is a MemberDef, because it contains schema.
If the schema inside the object is set to an array then it is a MemberDef. In the following example, subjectMarks
is a MemberDef, because it contains the schema of an array.
If the object does not fall under any of the above conditions then it is not a MemberDef. It is a schema of an object. The following example represents the object schema.