Parsing a Field Value

Prev Next

By using the parse flag in the schema, you can get a response like the one below where some of the data is stringified within the response. The individual fields will be parsed as well, so that they are returned as JSON.

Example: Request Token Schema with Parse

  "$id": "reqTokenSchema.json",
  "properties": {
    ….
    "Data": {
      "type": "object",
      "properties": {
        "Data": {
          "type": "string",
          "parse": true,
          "external_name": "Data"
        }
      },
      "external_name": "Data"
    }     ….
  },
  "definitions": {}
}

RESPONSE IF PARSE NOT TRUE

{
  "ResponseType": "SUCCESS",
  "Data": {
    "Message": "",
    "MessageType": "Success",
    "returnStatus": false,
    "RecordCount": 0,
    "Data": "[{\"siteid\":\"XXXXX\",\"ng_rtr_pair_nm\":\"XXXXXXX\",\"ngmadrtr_id1\":\"XXXXXX\",\"ngmadrtr_id2\":\"XXXXXX\",\"ng_rtr_port\":\"2/1/5\",\"eth_term_mso\":\"XXXXX\"}]"
  }

RESPONSE IF PARSE TRUE

{
  "ResponseType": "SUCCESS",
  "Data": {
    "Message": "",
    "MessageType": "Success",
    "returnStatus": false,
    "RecordCount": 0,
    "Data": [
      {
        "siteid": "XXXXX",
        "ng_rtr_pair_nm": "XXXXXXX", 
        "ngmadrtr_id1": "XXXXXX", 
        "ngmadrtr_id2": "XXXXXX", 
        "ng_rtr_port": "2/1/5",
        "eth_term_mso": "XXXXX"
      }
    ]
  }