有这样一个需求:
str = "{\"users\":[{\"id\":1010,\"username\":\"pt_test_15\",\"email\":\"[email protected]\"},{\"id\":1011,\"username\":\"pt_test_16\",\"email\":\"[email protected]\"},{\"id\":1022,\"username\":\"pt_test_27\",\"email\":\"[email protected]\"},{\"id\":1039,\"username\":\"pt_test_44\",\"email\":\"[email protected]\"},{\"id\":1059,\"username\":\"pt_test_63\",\"email\":\"[email protected]\"},{\"id\":1069,\"username\":\"pt_test_72\",\"email\":\"[email protected]\"},{\"id\":1080,\"username\":\"sp9255\",\"email\":\"[email protected]\"},{\"id\":1094,\"username\":\"peter\",\"email\":\"[email protected]\"},{\"id\":1111,\"username\":\"seekingalpha\",\"email\":\"[email protected]\"},{\"id\":1138,\"username\":\"peterchen\",\"email\":\"[email protected]\"}],\"term\":\"p\"}"
现要将 str 转换成一个数组,数组里边儿有五个 hash 格式如下(取五个):
[{:id=>1010,
:username=>"pt_test_15",
:email=>"[email protected]"},
{:id...
}]
求大神解答