Overview of the Structure of our Response format

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€44.11
List Price:  €61.76
You save:  €17.65
£37.48
List Price:  £52.47
You save:  £14.99
CA$69.05
List Price:  CA$96.68
You save:  CA$27.62
A$78.18
List Price:  A$109.46
You save:  A$31.28
S$65.39
List Price:  S$91.56
You save:  S$26.16
HK$387.71
List Price:  HK$542.83
You save:  HK$155.11
CHF 41.32
List Price:  CHF 57.85
You save:  CHF 16.53
NOK kr520.29
List Price:  NOK kr728.45
You save:  NOK kr208.15
DKK kr329.25
List Price:  DKK kr460.98
You save:  DKK kr131.72
NZ$84.30
List Price:  NZ$118.03
You save:  NZ$33.73
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.45
৳6,093.85
List Price:  ৳8,531.88
You save:  ৳2,438.02
₹4,229.68
List Price:  ₹5,921.90
You save:  ₹1,692.21
RM215.70
List Price:  RM302
You save:  RM86.30
₦80,298.43
List Price:  ₦112,424.23
You save:  ₦32,125.80
₨14,092.14
List Price:  ₨19,730.13
You save:  ₨5,637.98
฿1,673.16
List Price:  ฿2,342.56
You save:  ฿669.40
₺1,922.50
List Price:  ₺2,691.65
You save:  ₺769.15
B$284.73
List Price:  B$398.65
You save:  B$113.91
R932.17
List Price:  R1,305.11
You save:  R372.94
Лв86.31
List Price:  Лв120.84
You save:  Лв34.53
₩71,313.48
List Price:  ₩99,844.59
You save:  ₩28,531.10
₪180.90
List Price:  ₪253.27
You save:  ₪72.37
₱2,792.44
List Price:  ₱3,909.64
You save:  ₱1,117.20
¥7,213.15
List Price:  ¥10,098.99
You save:  ¥2,885.84
MX$981.88
List Price:  MX$1,374.71
You save:  MX$392.83
QR182.01
List Price:  QR254.83
You save:  QR72.82
P686.40
List Price:  P961.02
You save:  P274.61
KSh6,473.70
List Price:  KSh9,063.70
You save:  KSh2,590
E£2,540.12
List Price:  E£3,556.37
You save:  E£1,016.25
ብር6,728.99
List Price:  ብር9,421.13
You save:  ብር2,692.13
Kz45,590.88
List Price:  Kz63,830.88
You save:  Kz18,240
CLP$47,551.98
List Price:  CLP$66,576.58
You save:  CLP$19,024.60
CN¥364.67
List Price:  CN¥510.57
You save:  CN¥145.90
RD$2,951.01
List Price:  RD$4,131.65
You save:  RD$1,180.64
DA6,631.16
List Price:  DA9,284.16
You save:  DA2,652.99
FJ$112.94
List Price:  FJ$158.13
You save:  FJ$45.18
Q385.11
List Price:  Q539.19
You save:  Q154.07
GY$10,461.12
List Price:  GY$14,646.40
You save:  GY$4,185.28
ISK kr6,427.71
List Price:  ISK kr8,999.31
You save:  ISK kr2,571.60
DH463.01
List Price:  DH648.26
You save:  DH185.24
L860.69
List Price:  L1,205.03
You save:  L344.34
ден2,715.28
List Price:  ден3,801.61
You save:  ден1,086.33
MOP$400.55
List Price:  MOP$560.81
You save:  MOP$160.25
N$933.50
List Price:  N$1,306.98
You save:  N$373.47
C$1,845.09
List Price:  C$2,583.28
You save:  C$738.18
रु6,780.01
List Price:  रु9,492.56
You save:  रु2,712.54
S/183.84
List Price:  S/257.39
You save:  S/73.55
K204.72
List Price:  K286.62
You save:  K81.90
SAR187.47
List Price:  SAR262.47
You save:  SAR75
ZK1,395.21
List Price:  ZK1,953.40
You save:  ZK558.19
L219.61
List Price:  L307.47
You save:  L87.86
Kč1,099.09
List Price:  Kč1,538.82
You save:  Kč439.72
Ft17,827.75
List Price:  Ft24,960.28
You save:  Ft7,132.52
SEK kr485.20
List Price:  SEK kr679.32
You save:  SEK kr194.12
ARS$58,394.27
List Price:  ARS$81,756.65
You save:  ARS$23,362.38
Bs346.56
List Price:  Bs485.21
You save:  Bs138.65
COP$209,813.98
List Price:  COP$293,756.36
You save:  COP$83,942.38
₡25,326.52
List Price:  ₡35,459.16
You save:  ₡10,132.63
L1,301.19
List Price:  L1,821.77
You save:  L520.58
₲401,593.41
List Price:  ₲562,262.91
You save:  ₲160,669.49
$U2,097.63
List Price:  $U2,936.85
You save:  $U839.22
zł189.11
List Price:  zł264.76
You save:  zł75.65
Already have an account? Log In

Transcript

Going on with our code. Let's see how we will design our response objects. Always return JSON with an object on that side. This is what is stated by the open web application security project. Always have that site primitive be an object for JSON strings. As you can see from the examples, there are some safe and less safe way to structure your response object.

If you want to know something more about it or if you have, if you want to know the reasons behind these statements statement, please visit the link that I leave here at the bottom of this slide as a source. As you can see, there are some security reasons but I like to have a solid data format for my response objects. So what we are going to do is to create two Different response objects, one for the success response or one for the error response. For the sexual response, we will have our success attributes that will be through our studies could represent the HTTP status code, an optional message that describes that has some meaningful, meaningful message for the user. And the payload will contain the real resource what we have requested, the URL response will have a success attribute set to false on HTTP status code message and a call to the uniquely identifies the error.

So as you can see, and there is a common pattern and we can organize it in a common response. object that we have the success to the scope and message property. So we are going to extend this response to create the success response in the error response. Then we will have two functions that will take care of the setup of the response object in order to send the result of the requested operation. These are particularly useful if you want to add later sub procedures will or behavior for example, if you want to add an email at the end of the error response

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.