1

Below is the format of a sample JSON string currently returning and showing in Swagger UI . Is there a better way to get formatted JSON string returned and get displayed on UI without explicit String Replace function.

"IdentifierDetails": "{\"Id\":\"123456\",\"IdentifiedDate\":\"04/20/2020 1:24:35 PM\",\"Specification\":{\"City\":\"NEWYORK\",\"Country\":\"US\",\"FirstName\":\"Thomas\",\"LastName\":\"Paul\",\"Company\":\"AT&T\",\"InsuranceID\":\"1\2020\4566-7623245\"}}"

Expected:

"IdentifierDetails": "{"Id":"123456","IdentifiedDate":"04/20/2020 1:24:35 PM","Specification":{"City":"NEWYORK","Country":"US","FirstName":"Thomas","LastName":"Paul","Company":"AT&T","InsuranceID":"1\2020\4566-7623245"}}"
venkat
  • 5,648
  • 16
  • 58
  • 83
  • 1
    The first is a legal json fragment, the second isn't, I'd assume that was the reason. – Lasse V. Karlsen Apr 30 '20 at 17:15
  • 1) Is `IdentifierDetails` supposed to be a JSON object (i.e. `"IdentifierObject": {"Id": ...}` - note no quotes around `{}`), or a _string_ containing an object representation? 2) Is this sample JSON actually returned by your server (e.g. when you do "try it out") or is it just a _displayed_ example (e.g. autogenerated by Swagger UI)? – Helen Apr 30 '20 at 20:48

1 Answers1

0

Check if you can add below to content type and put json string in example.

mediaType = MediaType.APPLICATION_JSON_VALUE 
Abhinav manthri
  • 151
  • 1
  • 14