Forum: Ruby on Rails How to use nested arrays in ActionWebService?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
54532f023496410e0d7b1add5561ba45?d=identicon&s=25 Manuel Holtgrewe (Guest)
on 2006-01-31 18:16
(Received via mailing list)
Hi list.

I am writing a data structure definition for my web service API that
has - besides others - a nested array of integers: I want to have an
array that contains arrays which themselves contain two integer values.

An example for this is:

   [ [1, 2], [2, 400] ]

These values represent a distribution and in this exapmmle this means
that the event "hit 1 time" occured two times and "hit 2 times"
occured 400 times.

When I try to implement this the following way I get an error ("nil
where it was not expected, maybe you wanted an array instead"):

class ProductStatistics < ActionWebService::Struct
   member :name, :string

   member :hit_distribution, [[:int]]
end

When I changed this to a flat integer array, it worked:

class ProductStatistics < ActionWebService::Struct
   member :name, :string

   member :hit_distribution, [:int]
end

Now, my question: Is it possible to specify that I want nested arrays
of integers in my web service API and if yes: how?


Regards,

Manuel Holtgrewe
This topic is locked and can not be replied to.