mercredi 21 août 2019

JSON Schema : How to specify that a string property contains base64-encoded PNG images

By adding : The contentMediaType and contentEncoding

Example

Here is an example schema, illustrating the use of "contentEncoding" and "contentMediaType":
{
    "type": "string",
    "contentEncoding": "base64",
    "contentMediaType": "image/png"
}

                    
Instances described by this schema should be strings, and their values should be interpretable as base64-encoded PNG images.
Another example:
{
    "type": "string",
    "contentMediaType": "text/html"
}

                    

Instances described by this schema should be strings containing HTML, using whatever character set the JSON string was decoded into (default is Unicode)

 contentEncoding

If the instance value is a string, this property defines that the string SHOULD be interpreted as binary data and decoded using the encoding named by this property. RFC 2045, Sec 6.1 [RFC2045]lists the possible values for this property.

The value of this property MUST be a string.

contentMediaType

The value of this property must be a media type, as defined by RFC 2046 [RFC2046]. This property defines the media type of instances which this schema defines.
The value of this property MUST be a string.
The value of this property SHOULD be ignored if the instance described is not a string.
If the "contentEncoding" property is not present, but the instance value is a string, then the value of this property SHOULD specify a text document type, and the character set SHOULD be the character set into which the JSON string value was decoded (for which the default is Unicode).

3 commentaires:

  1. Hello! Hope you are having a good day. Your site has really good posts. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good work. We can also be helpful in developing your site, as our site provides the best web development tools. Here is the link jsononline

    RépondreSupprimer

to criticize, to improve