From: Jeremy Bopp Date: 2011-02-02T10:51:26+09:00 Subject: Re: remove array bracket On 02/01/2011 06:50 PM, Kamarulnizam Rahim wrote: > Hi when i run my script, the output is as followed: > > [{"name"=>"Efficiency (Energy)", > "type"=>"Objective", > "subtype"=>"NIZAMMMMzz", > "components"=> > [{"type"=>"ContentBox", "title"=>"Audit", > "args"=>{:content=>"None\n"}}, > {"type"=>"ChildListingComponent", > "title"=>"Current Targets for the Efficiency (Energy) > Objective:"}]}, > {"children"=> > [{"name"=>"Routinely monitor energy use", > "type"=>"Target", > "subtype"=>"ATEEN", > "components"=> > [{"type"=>"ContentBox", > "title"=>"Summary", > "args"=>{:content=>"None\n"}}, > {"type"=>"ContentBox", "title"=>"Description", > "args"=>{:content=>""}}, > {"type"=>"TargetComponent", > "title"=>"None", > "args"=> > {:start_date=>"# :end_date=>"5/1/2011", > :state=>"Active"}}]}]}, > ........... > ........... > :state=>"Active"}}]}]}] > > How do i tell ruby to remove the very first and the very last bracket > '[...]' out from my output? How does your script produce that output in the first place? I'm going to assume that you have a reference to an array and that you're printing the output of that array's inspect method. In that case, you could try something like this: array = ... # Array value from somewhere puts array.map(&:inspect).join(", ") This code maps each element of the array to the value of its associated inspect method and then joins all elements of the array with ", ". You should be able to use similar logic if you are using something other than the inspect method as well. -Jeremy