Receiving a JSON string & saving one of the array paramaters to the database as a full string

Posted by ElTren on Stack Overflow See other posts from Stack Overflow or by ElTren
Published on 2010-05-04T05:26:05Z Indexed on 2010/05/04 5:48 UTC
Read the original article Hit count: 260

Filed under:
|
|

Hi I have a JSON string that looks like this (Usingt Rails and a REST service)

  {  
   person:   
      {
         name:"Pepe",
         last:"Smith"
         hats:[ { team:"lakers", color:"purple"}, { team:"heats", color:"red" }]   }   }

I want to be able to able to get that JSON, and save the Person to the database, but I want to save the "hats".. as a string to the database; without parsing it or anything like that

i.e. I want to save this to SQL:

hats = "[ { team:"lakers", color:"purple"}, { team:"heats", color:"red" }] }"

Is there a way to do this in rails?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about restful