我有以下单行字符串:
params = {"FieldStructure"=>"{\"Fields\":[{\"Title\":\"Company Name\",\"Type\":\"text\",\"ID\":\"Field6\"},{\"Title\":\"Email\",\"Type\":\"email\",\"ID\":\"Field5\"}]}", "Field6"=>"tettetette", "Field5"=>"test@tessss.pl", "EntryId"=>"25"}
格式化版:
params = {
"FieldStructure"=>"
{\"Fields\":[
{\"Title\":\"Company Name\",\"Type\":\"text\",\"ID\":\"Field6\"},
{\"Title\":\"Email\",\"Type\":\"email\",\"ID\":\"Field5\"}]}",
"Field6"=>"tettetette",
"Field5"=>"test@tessss.pl",
"EntryId"=>"25"
}
我想收到:[["Company Name", "Field6"], ["Email", "Field5"]]
我尝试使用扫描方法但有一些问题:
>> fields = params['FieldStructure'].scan(/Title\":\"(.+?)\".+ID\":\"(.+?)\"/)
=> [["Company Name", "Field5"]]
如何做到这一点?