can you help me to solve this problem with this code?
total_user_input = []
while true
print "Field Name: "
user_input = gets.chomp
break if user_input.empty?
total_user_input << user_input
end
total_user_input.each do |input|
aa = input.split(":").reduce {|first, second| " \t'#{first}': '#{second}',\r\n".gsub("'",'"') }
puts aa.chomp(',')
end
and the result I get
"name": "string",
"desc": "string",
"price": "integer",
but what I want is just remove the last comma only
"name": "string",
"desc": "string",
"price": "integer"
thank you for helping me
I don't know actualy what your scenario But I base on your expected and You can try it.
=> My result