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
€43.65
List Price:  €61.12
You save:  €17.46
£37.73
List Price:  £52.83
You save:  £15.09
CA$68.48
List Price:  CA$95.88
You save:  CA$27.39
A$71.16
List Price:  A$99.63
You save:  A$28.47
S$64.02
List Price:  S$89.63
You save:  S$25.61
HK$391.46
List Price:  HK$548.08
You save:  HK$156.61
CHF 39.45
List Price:  CHF 55.24
You save:  CHF 15.78
NOK kr486.15
List Price:  NOK kr680.65
You save:  NOK kr194.49
DKK kr326.22
List Price:  DKK kr456.73
You save:  DKK kr130.51
NZ$85.85
List Price:  NZ$120.20
You save:  NZ$34.34
د.إ183.58
List Price:  د.إ257.03
You save:  د.إ73.45
৳6,144.50
List Price:  ৳8,602.80
You save:  ৳2,458.29
₹4,620.07
List Price:  ₹6,468.47
You save:  ₹1,848.39
RM196.48
List Price:  RM275.09
You save:  RM78.61
₦69,356.62
List Price:  ₦97,104.82
You save:  ₦27,748.20
₨13,981.74
List Price:  ₨19,575.56
You save:  ₨5,593.81
฿1,626.04
List Price:  ฿2,276.59
You save:  ฿650.55
₺2,209.10
List Price:  ₺3,092.92
You save:  ₺883.81
B$268.30
List Price:  B$375.65
You save:  B$107.34
R843.76
List Price:  R1,181.33
You save:  R337.57
Лв85.38
List Price:  Лв119.54
You save:  Лв34.16
₩74,787.50
List Price:  ₩104,708.49
You save:  ₩29,920.98
₪156.79
List Price:  ₪219.52
You save:  ₪62.72
₱2,989.35
List Price:  ₱4,185.33
You save:  ₱1,195.98
¥7,964.55
List Price:  ¥11,151.01
You save:  ¥3,186.45
MX$891.91
List Price:  MX$1,248.74
You save:  MX$356.83
QR182.02
List Price:  QR254.85
You save:  QR72.82
P682.34
List Price:  P955.34
You save:  P272.99
KSh6,462.70
List Price:  KSh9,048.30
You save:  KSh2,585.60
E£2,620.81
List Price:  E£3,669.34
You save:  E£1,048.53
ብር7,816.27
List Price:  ብር10,943.40
You save:  ብር3,127.13
Kz45,597.42
List Price:  Kz63,840.04
You save:  Kz18,242.62
CLP$46,025.29
List Price:  CLP$64,439.09
You save:  CLP$18,413.80
CN¥344.74
List Price:  CN¥482.66
You save:  CN¥137.92
RD$3,076.41
List Price:  RD$4,307.22
You save:  RD$1,230.81
DA6,623.73
List Price:  DA9,273.75
You save:  DA2,650.02
FJ$110.99
List Price:  FJ$155.39
You save:  FJ$44.40
Q384
List Price:  Q537.63
You save:  Q153.63
GY$10,476.18
List Price:  GY$14,667.49
You save:  GY$4,191.31
ISK kr6,296.24
List Price:  ISK kr8,815.24
You save:  ISK kr2,519
DH471.62
List Price:  DH660.30
You save:  DH188.68
L875.48
List Price:  L1,225.75
You save:  L350.26
ден2,692.03
List Price:  ден3,769.07
You save:  ден1,077.03
MOP$403.66
List Price:  MOP$565.16
You save:  MOP$161.49
N$841.02
List Price:  N$1,177.50
You save:  N$336.47
C$1,842.53
List Price:  C$2,579.69
You save:  C$737.15
रु7,395.40
List Price:  रु10,354.15
You save:  रु2,958.75
S/172.68
List Price:  S/241.76
You save:  S/69.08
K218.96
List Price:  K306.56
You save:  K87.60
SAR187.58
List Price:  SAR262.64
You save:  SAR75.05
ZK974.65
List Price:  ZK1,364.60
You save:  ZK389.94
L222.40
List Price:  L311.38
You save:  L88.98
Kč1,066.96
List Price:  Kč1,493.84
You save:  Kč426.87
Ft17,099.08
List Price:  Ft23,940.09
You save:  Ft6,841
SEK kr470.37
List Price:  SEK kr658.56
You save:  SEK kr188.18
ARS$69,898.52
List Price:  ARS$97,863.52
You save:  ARS$27,965
Bs346.01
List Price:  Bs484.45
You save:  Bs138.43
COP$184,354.73
List Price:  COP$258,111.38
You save:  COP$73,756.64
₡23,559.94
List Price:  ₡32,985.81
You save:  ₡9,425.86
L1,325.48
List Price:  L1,855.78
You save:  L530.30
₲323,053.08
List Price:  ₲452,300.17
You save:  ₲129,247.08
$U2,018.88
List Price:  $U2,826.59
You save:  $U807.71
zł186.41
List Price:  zł260.99
You save:  zł74.57
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.