Object
An object is the fundamental unit of Internet Object document, it can be defined with the members such as schema
, type
, default
, optional
and null
.
TypeDefs Schema
The TypeDef schema ensures the validity of object
MemberDefs.
schema
In the internet object document, the object may or may not be defined with the member called schema
. But it is always recommended to define the schema for an object.
If the schema is not defined then the user can pass an object with values of any
type i.e anyOf: [string, object]
.
The above code snippet represents how the object can be defined with the typedef member schema
.
type
The second member of the typedef is type
. By default, the object can be of string or an object type. Here the next snippet shows how the object type can be defined.
default
The next member in the object
typedef is default
. Here is how the default values can be defined for an object.
null
The Object when set to null
will accept null values. Here the code snippet demonstrates the way how an object can accept a null value.
optional
A member of an object type can be set to optional. Here are some of the ways through which a member of an object type can be made optional.
Designing Object Schema
Empty Object
An empty object is useful for accepting any object value irrespective of its structure. The empty object definitions can be created using empty curly braces syntax or ignoring schema. Here are some ways in which empty object definitions can be created.
Simple Object
A simple object is an ordered collection of key-value pair that avoids nesting of the object and may or may not contain a child object as shown in the code snippet.
With Memberdef
An object can be defined with the MemberDef as shown in the snippet below.
Nested Object
An Object can be nested inside another object. Accessing a nested object is similar to accessing a nested array. Here is the code snippet that shows how objects can be nested.
Dynamic Schema
Defining dynamic schema allows users to add a dynamic object as shown in the snippet below.
Schema or MemberDef
The object can be represented as MembeDef or Schema as shown here.
Last updated