Guest User

Untitled

a guest
Feb 28th, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.30 KB | None | 0 0
  1. public class MyClass {
  2. private long id;
  3. private String name;
  4.  
  5. public MyClass() {}
  6.  
  7. public MyClass (long id, String name) {
  8. this.id = id;
  9. this.name = name;
  10. }
  11.  
  12. public long getId() {
  13. return this.id;
  14. }
  15.  
  16. public String getName() {
  17. return this.name;
  18. }
  19. }
  20.  
  21. public class MyResponseWrapper {
  22. private MyClass[] myClassArray;
  23.  
  24. public MyResponseWrapper() {
  25. // this empty constructor is always being called
  26. }
  27.  
  28. public MyResponseWrapper(MyClass[] myClassArray) {
  29. this.myClassArray = myClassArray;
  30. }
  31.  
  32. public MyClass[] getMyClassArray() {
  33. return this.myClassArray;
  34. }
  35. }
  36.  
  37. RestTemplate restTemplate = new RestTemplate();
  38. HttpHeaders headers = new HttpHeaders();
  39. headers.set("Accept", "application/json");
  40. HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
  41. ResponseEntity<MyResponseWrapper> res = restTemplate.exchange(url, HttpMethod.GET, entity, MyResponseWrapper.class);
  42.  
  43. {
  44. "authorities":[
  45. {
  46. "LocalAuthorityId":197,
  47. "LocalAuthorityIdCode":"760",
  48. "Name":"Aberdeen City",
  49. "FriendlyName":"aberdeen-city",
  50. "Url":"http://www.aberdeencity.gov.uk",
  51. "SchemeUrl":"",
  52. "Email":"commercial@aberdeencity.gov.uk",
  53. "RegionName":"Scotland",
  54. "FileName":"http://ratings.food.gov.uk/OpenDataFiles/FHRS760en-GB.xml",
  55. "FileNameWelsh":null,
  56. "EstablishmentCount":1847,
  57. "CreationDate":"2010-08-17T15:30:24.87",
  58. "LastPublishedDate":"2018-02-08T00:35:50.717",
  59. "SchemeType":2,
  60. "links":[
  61. {
  62. "rel":"self",
  63. "href":"http://api.ratings.food.gov.uk/authorities/197"
  64. }
  65. ]
  66. },
  67. {
  68. "LocalAuthorityId":198,
  69. "LocalAuthorityIdCode":"761",
  70. "Name":"Aberdeenshire",
  71. "FriendlyName":"aberdeenshire",
  72. "Url":"http://www.aberdeenshire.gov.uk/",
  73. "SchemeUrl":"",
  74. "Email":"environmental@aberdeenshire.gov.uk",
  75. "RegionName":"Scotland",
  76. "FileName":"http://ratings.food.gov.uk/OpenDataFiles/FHRS761en-GB.xml",
  77. "FileNameWelsh":null,
  78. "EstablishmentCount":2102,
  79. "CreationDate":"2010-08-17T15:30:24.87",
  80. "LastPublishedDate":"2018-02-24T00:34:15.547",
  81. "SchemeType":2,
  82. "links":[
  83. {
  84. "rel":"self",
  85. "href":"http://api.ratings.food.gov.uk/authorities/198"
  86. }
  87. ]
  88. },
  89. {
  90. "LocalAuthorityId":277,
  91. "LocalAuthorityIdCode":"323",
  92. "Name":"Adur",
  93. "FriendlyName":"adur",
  94. "Url":"http://www.adur-worthing.gov.uk",
  95. "SchemeUrl":"",
  96. "Email":"publichealth.regulation@adur-worthing.gov.uk",
  97. "RegionName":"South East",
  98. "FileName":"http://ratings.food.gov.uk/OpenDataFiles/FHRS323en-GB.xml",
  99. "FileNameWelsh":null,
  100. "EstablishmentCount":417,
  101. "CreationDate":"2010-08-17T15:30:24.87",
  102. "LastPublishedDate":"2018-02-28T00:36:33.987",
  103. "SchemeType":1,
  104. "links":[
  105. {
  106. "rel":"self",
  107. "href":"http://api.ratings.food.gov.uk/authorities/277"
  108. }
  109. ]
  110. },
  111. {
  112. "LocalAuthorityId":158,
  113. "LocalAuthorityIdCode":"055",
  114. "Name":"Allerdale",
  115. "FriendlyName":"allerdale",
  116. "Url":"http://www.allerdale.gov.uk",
  117. "SchemeUrl":"",
  118. "Email":"environmental.health@allerdale.gov.uk",
  119. "RegionName":"North West",
  120. "FileName":"http://ratings.food.gov.uk/OpenDataFiles/FHRS055en-GB.xml",
  121. "FileNameWelsh":null,
  122. "EstablishmentCount":1092,
  123. "CreationDate":"2010-08-17T15:30:24.87",
  124. "LastPublishedDate":"2018-02-28T00:33:58.31",
  125. "SchemeType":1,
  126. "links":[
  127. {
  128. "rel":"self",
  129. "href":"http://api.ratings.food.gov.uk/authorities/158"
  130. }
  131. ]
  132. },
  133. {
  134. "LocalAuthorityId":48,
  135. "LocalAuthorityIdCode":"062",
  136. "Name":"Amber Valley",
  137. "FriendlyName":"amber-valley",
  138. "Url":"http://www.ambervalley.gov.uk",
  139. "SchemeUrl":"",
  140. "Email":"envhealth@ambervalley.gov.uk",
  141. "RegionName":"East Midlands",
  142. "FileName":"http://ratings.food.gov.uk/OpenDataFiles/FHRS062en-GB.xml",
  143. "FileNameWelsh":null,
  144. "EstablishmentCount":972,
  145. "CreationDate":"2010-08-17T15:30:24.87",
  146. "LastPublishedDate":"2018-02-28T00:34:14.493",
  147. "SchemeType":1,
  148. "links":[
  149. {
  150. "rel":"self",
  151. "href":"http://api.ratings.food.gov.uk/authorities/48"
  152. }
  153. ]
  154. },
  155. {
  156. "LocalAuthorityId":334,
  157. "LocalAuthorityIdCode":"551",
  158. "Name":"Anglesey",
  159. "FriendlyName":"anglesey",
  160. "Url":"http://www.ynysmon.gov.uk",
  161. "SchemeUrl":"",
  162. "Email":"iechydyramgylchedd@ynysmon.gov.uk",
  163. "RegionName":"Wales",
  164. "FileName":"http://ratings.food.gov.uk/OpenDataFiles/FHRS551en-GB.xml",
  165. "FileNameWelsh":"http://ratings.food.gov.uk/OpenDataFiles/FHRS551cy-GB.xml",
  166. "EstablishmentCount":703,
  167. "CreationDate":"2010-08-17T15:30:24.87",
  168. "LastPublishedDate":"2018-02-28T00:34:28.853",
  169. "SchemeType":1,
  170. "links":[
  171. {
  172. "rel":"self",
  173. "href":"http://api.ratings.food.gov.uk/authorities/334"
  174. }
  175. ]
  176. }
  177. ],
  178. "meta":{
  179. "dataSource":"API",
  180. "extractDate":"2018-02-28T00:58:26.2673908+00:00",
  181. "itemCount":6,
  182. "returncode":"OK",
  183. "totalCount":6,
  184. "totalPages":1,
  185. "pageSize":6,
  186. "pageNumber":1
  187. },
  188. "links":[
  189. {
  190. "rel":"self",
  191. "href":"http://api.ratings.food.gov.uk/authorities"
  192. },
  193. {
  194. "rel":"first",
  195. "href":"http://api.ratings.food.gov.uk/authorities/1/6"
  196. },
  197. {
  198. "rel":"previous",
  199. "href":"http://api.ratings.food.gov.uk/authorities/1/6"
  200. },
  201. {
  202. "rel":"next",
  203. "href":"http://api.ratings.food.gov.uk/authorities/1/6"
  204. },
  205. {
  206. "rel":"last",
  207. "href":"http://api.ratings.food.gov.uk/authorities/1/6"
  208. }
  209. ]
  210. }
Add Comment
Please, Sign In to add comment