Examples of data models using JSON sample

You can create a data model for simple JSON strings, with strings having nested objects, multiple objects, and an array of data.

This topic provides examples of data models that are based on sample JSON strings using the employee details for the different data models.

Example of a simple string

This sample includes employee details, such as name, job, id, and created at.

{
    "name": "Morpheush",
    "job": "Leader",
    "id": "199",
    "createdAt": "2020-02-20T11:00:28.107Z"
}

The above JSON sample creates the following 'Employee' model.

Field Name

Field Type

Name

String

Job

String

ID

String

CreatedAt

Date

Example of a string with a nested object

In addition to the simple employee details, this sample includes 'contactdetails' as a nested object, which includes Phone and Email fields.

{
    "name": "Morpheus",
    "job": "Leader",
    "id": "199",
    "createdAt": "2020-02-20T11:00:28.107Z"
    "contactdetails": {
	          "phone”:”8439743294793",
          	"email":"test@abc.com"
	         }
}

The above JSON sample creates the following structure.

Field Name

Field Type

Name

String

Job

String

ID

String

CreatedAt

Date

Contact details

  • Phone

  • Email

Object

  • String

  • String

Example of a string with multiple objects

This sample includes two objects: Address and Profile.

{
 "empid": "SJ011MS",
 "personal":
  {
  "name":"Smith Jones",
  "gender":"Male",
  "age": 28,
  "address":
   {
   "streetaddress":"724th Street",
   "city":"New York",
   "state": "NY",
   "postalcode":"10038"
   }
  },
 "profile":
  {
  "designation":"Deputy General",
  "department":"Finance"
  }
}

The above JSON sample creates the following structure.

Field Name

Field Type

Empid

String

Personal

String

Name

String

Gender

String

Age

Numeric

Address

  • Streetaddress

  • City

  • Postcode

  • State

Object

  • String

  • String

  • String

  • String

Profile

  • Designation

  • Department

Object

  • String

  • String

Example of a string with an array of data

This sample includes a list of data to be included on a page.

{ 
 "page": 1, 
 "per_page": 6, 
 "total": 12, 
 "total_pages":14, 
 "data": [
     {
      "id": 1,
      "name": "cerulean",
      "year": 2000,
      "color": "#98B2D1",
      "pantone_value": "15-4020"
     },
     {
      "id": 2,
      "name": "fuchsia rose", 
      "year": 2001, 
      "color": "#C74375",
      "pantone_value": "17-2031"
     },
     {
      "id": 3, 
      "name": "true red", 
      "year": 2002, 
      "color": "#BF1932", 
      "pantone_value": "19-1664" 
     }, 
     {
      "id": 4, 
      "name": "aqua sky",
      "year": 2003,
      "color": "#7BC4C4",
      "pantone_value": "14-4811"
     },
     { 
      "id": 5,
      "year": 2004, 
      "color": "#E2583E", 
      "pantone_value": "17-1456" 
     },
     {  
      "id": 6, 
      "name": "blue turquoise", 
      "year": 2005,            
      "color": "#53B0AE",
      "pantone_value": "15-5217"
     }
      ]
} 

The above JSON sample creates the following structure.

Field Name

Field Type

Page

Numeric

Per_page

Numeric

Total

Numeric

Total_pages

Numeric

Data

  • id

  • Name

  • Year

  • Color

  • Pantone_value

Complex

  • String

  • Numeric

  • String

  • String

  • String