How to define Enumeration in JSON

0

I have the following enumeration in XSD for a WSDL

<xsd:simpleType name="tipoDocumento">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="INICIAL"/>
        <xsd:enumeration value="FINAL"/>
        <xsd:enumeration value="JUSTIFICATIVA"/>
    </xsd:restriction>
</xsd:simpleType>

I'm converting the same to JSON

How do I define the above enumeration on a JSON interface?

    
asked by anonymous 03.07.2017 / 13:48

2 answers

1

JSON is a message format such as XML. XSD (Schema Definition) is a format used to shape and validate a structure in XML.

For JSON there are some framework recognition / validation patterns, for example:

  • JSON Schema - similar to XSD for validation and recognition of JSON structures
  • Swagger : notation to draw a REST API and it can specify the input and output structures
  • RAML - other notation to specify the contract of a REST API
04.07.2017 / 04:25
0

JSON is not a syntax-rich format to indicate various semantics. He leaves it to anyone who interprets it, who is responsible enough to interpret it correctly. JSON only sends information back and forth.

As it depends a lot on the reader side, you have many options on how to do this. One of these options is:

{
    'tipoDocumento': ['INICIAL', 'FINAL', 'JUSTIFICATIVA']
}
    
03.07.2017 / 14:19