These are chat archives for opal/opal

6th
Feb 2018
Frederic ZINGG
@fzingg
Feb 06 2018 09:23

Hi huys,

What is the best way to get DATAS from a HTML FORMDATA and convert it to JSON.
I tried:

createdata = Element['#createform']
HTTP.post('/api/create', data: JSON.generate(createdata), dataType: :json) do |response|
end
Tx
Elia Schito
@elia
Feb 06 2018 09:27

@fzingg I have this in my current project:

class Element
  def serialize_array
    `self.serializeArray()`.map { |e| Hash.new(e) }
  end
end

but be aware that data coming from a form could different from what you expect in a JSON, this caught me offguard in the past

Frederic ZINGG
@fzingg
Feb 06 2018 09:29
@elia Ok, I will try, Tx !