Enterprise Developer enables you to automatically convert JSON data and generate COBOL classes when you paste the data into a COBOL file which is part of a .NET COBOL project.
This converts your JSON data to COBOL classes and adds it to the COBOL file.
The class and property names are generated as follows:
The following example shows the result of converting some film data in JSON format to COBOL classes using Paste JSON As Classes:
| JSON code | COBOL classes |
|---|---|
{
"$schema":"http:\/\/json-schema.org\/draft-04\/schema#",
"title": "JSON restful schema for film library Operations",
"type": "object",
"properties":
{
"film-details":
{
"type": "array",
"minItems": 1,
"items":
{
"type": "object",
"properties":
{
"title":
{
"type": "string",
"maxLength": 60
},
"year":
{
"type": "string",
"maxLength": 4
},
"director":
{
"type": "string",
"maxLength": 20
},
"format":
{
"type": "string",
"maxLength": 10
}
},
"required":[
"title",
"year",
"director",
"format"
]
}
}
}
}
|
class-id Rootobject.
01 schema string property.
01 #title string property.
01 #type string property.
01 #properties type Properties property.
end class.
class-id Properties.
01 filmdetails type FilmDetails property.
end class.
class-id FilmDetails.
01 #type string property.
01 minItems binary-long property.
01 items type Items property.
end class.
class-id Items.
01 #type string property.
01 #properties type Properties1 property.
01 #required string occurs any property.
end class.
class-id Properties1.
01 #title type Title property.
01 year type Year property.
01 director type Director property.
01 #format type Format property.
end class.
class-id Title.
01 #type string property.
01 maxLength binary-long property.
end class.
class-id Year.
01 #type string property.
01 maxLength binary-long property.
end class.
class-id Director.
01 #type string property.
01 maxLength binary-long property.
end class.
class-id Format.
01 #type string property.
01 maxLength binary-long property.
end class.
|