Is Object, a MemberDef or a Schema?
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.
When the first value is a datatype
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.
When the first value is an object
If the first value in the object is an object then it is a MemberDef. In the following example, testValue
is a MemberDef, as it defines the object as its first value.
If the first value is an array
If the first value in the object is an array then it is a MemberDef. In the following example, rollNumber
is a MemberDef, as it defines an array of an integer as its first value.
If the first value is a type
If the first value in the object is a type then it is MemberDef. In the following example, testScore
is a MemberDef, as it defines the type of object.
If the object contains schema
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 is set to an array in the object
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 conditions given above
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.
Last updated