Home > Enterprise >  Create a New JSON format from another JSON in Ruby on Rails
Create a New JSON format from another JSON in Ruby on Rails

Time:09-14

I'm new to ruby on rails and I'm trying to manipulate the json data into another json format. I have this Controller,thats calls API service URL: enter image description here

-----UPDATE ----

I can actually use the rocket symbol by doing the field as "api" not :api as I previously used.

@entrylist = obj['entries'].map do |e|
  { "api"=> e["API"] , "desc"=> e["Description"] }
end

CodePudding user response:

Just need to reference the API/Description methods as keys, not methods:

@entrylist = obj['entries'].map do |e|
  { api: e["API"] , desc: e["Description"] }
end
  • Related