2

Can anyone help me how to decode JSON object from Rails. Basically I have javascript function that encode JSON object and pass it to rails.

function save(){
----
----   
notesArray.push({ Index: i, Title: title.val(), Content: content.val()});

// json encode it
var jsonStr = JSON.stringify(notesArray);

//sending to rails
$.post('monkey', {notes: jsonStr});
}

I don't know how to decode this in my controllers in Rails. I also want it to save it in my database(SQLite). Any idea how to do this?

1 Answer 1

4
obj = ActiveSupport::JSON.decode(json_string)

But it's slow, check out this for a much faster extension: http://flori.github.com/json/

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.