So generieren Sie JSON -Daten von JSON Schema programmatisch in JavaJava

Java-Forum
Anonymous
 So generieren Sie JSON -Daten von JSON Schema programmatisch in Java

Post by Anonymous »

Ich versuche, Body-Parameter (JSON) für meine Post-API zu erstellen, eine JSON-Anfrage. Alles was ich habe ist das JSON -Schema. Ich versuche eine Liste verschiedener JSON -Testdaten zu finden, die positive und negative Flüsse dafür abdecken. Java? . Ich habe ein kleines JSON -Schema beigefügt (nur zum Verständnis), aber mein tatsächliches Schema ist komplizierter mit vielen Arrays und verschachtelten JSONs. < /p>

Mein JSON -Schema: < /p>

{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "http://example.com/example.json",
"type": "object",
"title": "The Root Schema",
"description": "The root schema comprises the entire JSON document.",
"required": [
"FirstName",
"LastName",
"Age",
"Interest"
],
"properties": {
"FirstName": {
"$id": "#/properties/FirstName",
"type": "string",
"title": "The Firstname Schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"Vijay"
]
},
"LastName": {
"$id": "#/properties/LastName",
"type": "string",
"title": "The Lastname Schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"Karthik"
]
},
"Age": {
"$id": "#/properties/Age",
"type": "integer",
"title": "The Age Schema",
"description": "An explanation about the purpose of this instance.",
"default": 0,
"examples": [
30
]
},
"Interest": {
"$id": "#/properties/Interest",
"type": "array",
"title": "The Interest Schema",
"description": "An explanation about the purpose of this instance.",
"default": [],
"items": {
"$id": "#/properties/Interest/items",
"type": "string",
"title": "The Items Schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"Food",
"movie",
"Learning",
"VideoGames"
]
}
}
}
< /code>

}enter code here< /code> < /p>

Mein testdata sieht aus wie: < /p>

{
"FirstName":"Vivi",
"LastName":"Karrri",
"Age":30,
"Interest":["Food","movie","Learning","VideoGames"]
}
< /code>

Vorschläge Wie können wir dies erreichen?
Hinweis: Ich verwende Spring Start und habe ein komplettes Pojo für das Anforderungsobjekt < /p>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post