0

I have a survey-field containing JSON data like this:

{
    "reason":
    {
        "0":"first",
        "1":"second",
        "other":["on","third"]
    },
    "comment":"fourth"
}

I want to select the first,second,third and fourth values in SQL.

Thank you.

4
  • use $result=json_decode($array,true); print_r($result); Commented Feb 15, 2013 at 10:33
  • I think we misunderstood each other. I want to do it only in SQL. Commented Feb 15, 2013 at 10:38
  • is the structure same always? Commented Feb 15, 2013 at 10:39
  • Yes, it is always like this. Only there can be 2,3,4... but it always starts with 0 and there is always an other and a comment. Commented Feb 15, 2013 at 10:49

1 Answer 1

1
var JSONObject = {"reason":{"0":"first","1":"second","other":["on","third"]},"comment":"fourth"};

document.getElementById("first").innerHTML=JSONObject.reason[0];

document.getElementById("second").innerHTML= JSONObject.reason[1];

document.getElementById("comment").innerHTML= JSONObject.comment[0];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.