0

How to define the json schema for array of json objects . How to write schema for this json example

example :

[
 {
   "name" : "amy",
   "Age"   : "25" 
 },
 {
   "name" : "john", 
   "Age"   : "20"
 }
]

Tried in different ways but not working.

XaC
  • 432
  • 3
  • 9
  • Could you share what you tried, and in why you say that it's not working? – XaC Jan 13 '23 at 20:03
  • { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { "ClaimDetails": { "type": "array", "items": { "type": "object", "description": "List of all Claimant details", "properties": { "name": { "description": "name of the claimant", "type": "string" }, "age": { "description": "age of the claimant", "type": "string" } } } } } }API definition is not loading in swagger-ui for the above – Lavanya . A Jan 14 '23 at 05:40
  • I'm able to achieve below sample json { "ClaimPayments": [ { "Checknum": "1234567", "losscode": "1345" }, { "Checknum": "098765432", "losscode": "0000" } ] } using below schema { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { "ClaimDetails": { "properties": { "ClaimPayments": { "type": "array", "items": { "$ref": "#/definitions/claiminfo" } }} },"claiminfo" : { "properties": { "Checknum" : { "type": "string" },"losscode": { "type": "string" }}}}} – Lavanya . A Jan 14 '23 at 06:54

0 Answers0