Get a JSON object from a MySQL text field

Hi,

my application has some text fields inside a MySQL database containing JSON objects. I want the REST-API to return them inline in the JSON response as native JSON. As the default, the API returns them as escaped strings, so that the API consumer has to JSON decode them on their own.

Example given, this is what comes out of the API now:

{
  "contact_data": "[{\n  \"type\": \"phone\",\n  \"name\": \"Telefon\",\n  \"value\": \"+49 321 123456\"\n},{\n  \"type\": \"email\",\n  \"name\": \"E-Mail\",\n  \"value\": \"user@domain.de\"\n}]"
}

This is what I want:

{
  "contact_data": [
    {
      "type": "phone",
      "name": "Telefon",
      "value": "+49 321 123456"
    },{
      "type": "email",
      "name": "E-Mail",
      "value": "user@domain.de"
    }
  ]
}

Any ideas how to get this done? And what about writing those fields?

Greets,
spackmat

We had someone a while back serializing the JSON and storing it mysql, I don’t see it here in the forums, let me look at that up and post back here shortly. Definitely possible with or without serializing.

We solved this client side in our Ember.js application with JSON.parse() and JSON.stringify(). But it would be cool, when Dreamfactory could solve this on its own.