How to define Enumeration in JSON

Asked

Viewed 1,178 times

0

I have the following enumeration on 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 am converting the same to JSON

How I define the enumeration above in a JSON interface?

2 answers

1


JSON is a message format like XML. XSD (Schema Definition) is a format used to shape and validate an XML structure.

For JSON there are some structure 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 in it the input and output structures can be specified
  • RAML - another notation to specify the contract of a REST API
  • 1

    Very interesting thank you

0

JSON is not a syntax-rich format to indicate several semantics. He leaves it to whoever is interpreting him, who is responsible enough to interpret it correctly. JSON only sends information back and forth.

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

{
    'tipoDocumento': ['INICIAL', 'FINAL', 'JUSTIFICATIVA']
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.