Examples of data models using JSON sample

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

This topic provides the examples of data models that are based on sample JSON string. The Employee details are taken for the different data models.

Example with 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 with nested object

In addition to the simple employee details, this sample includes 'contactdetails' as 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 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 with array of data

This sample includes a list of data to be included in 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