I assume that what you are showing as the "rest API response". If so you need to clean it up so that it is a valid JSON string, convert it to a hash and then extract the array you want.
str =<<_
{ "functionality":[], "subfunctionality": [{"id":1, "title":"a1", "description":"sample},
{"id":2, "title":"a2", "description":"sample},
{"id":3, "title":"a3", "description":"sample}
_
require 'json'
a = JSON.parse(str.gsub("\"sample", "\"sample\"") << ']}')["subfunctionality"]
#=> [{"id"=>1, "title"=>"a1", "description"=>"sample"},
# {"id"=>2, "title"=>"a2", "description"=>"sample"},
# {"id"=>3, "title"=>"a3", "description"=>"sample"}]
The steps are as follows.
s = str.gsub("\"sample", "\"sample\"") << ']}'
#=> "{ \"functionality\":[], \"subfunctionality\": [{\"id\":1, \"title\":\"a1\",
# \"description\":\"sample\"},\n{\"id\":2, \"title\":\"a2\",
# \"description\":\"sample\"}, \n{\"id\":3, \"title\":\"a3\",
# \"description\":\"sample\"}\n]}"
h = JSON.parse(s)
#=> {"functionality"=>[],
# "subfunctionality"=>[{"id"=>1, "title"=>"a1", "description"=>"sample"},
# {"id"=>2, "title"=>"a2", "description"=>"sample"},
# {"id"=>3, "title"=>"a3", "description"=>"sample"}]}
h["subfunctionality"]
#=> (return value shown above)
Note that I've broken the string s
in various places to make it easier to read.