0

I need to model a nested data structure with an array of an array of numbers. Ex:

"measures": [
  [1, 91.3],
  [2, 87.5],
  ...

I tried like this:

"mmeasures": {
  "type": [ [ "Number" ] ]
},

But it does not seem to work.

The corresponding loopback docs do not mention nested arrays.

vanthome
  • 4,816
  • 37
  • 44
  • Hi, Can you explain the business case you need this? It could be the case that a simply using and object with an array { [ ] } , could do the trick. Or maybe you need a matrix? [ ] [ ] . Other possibility to consider would be to use constructor i.e - let myArrOfArr = new Array(new Array( )); – groo Jun 04 '16 at 08:19
  • I think the business case does not matter at all here, I asked a clear question. The matrix solution also does not work as it is not even valid JS. – vanthome Jun 06 '16 at 19:37
  • Hi, so.. did you notice in my previous comment the part "It could be the case that a simply using and object with an array { [ ] } , could do the trick" that was exactly the solution you published as valid below :) . Asking about the business case I was just trying to understand to see if that would fit the case. – groo Jun 07 '16 at 17:39
  • No it isn't the solution. I'm simply not using an object, neither in the model nor in the real data. – vanthome Jun 07 '16 at 21:14
  • Hi, humm.. it looks like you're missing basic concepts of javascript, please check this sources and you'll possibly understand: http://stackoverflow.com/questions/1828924/array-inside-a-javascript-object http://eloquentjavascript.net/04_data.html – groo Jun 07 '16 at 21:30

1 Answers1

0

An array of any typed values did the trick:

"mmeasures": {
  "type": [ "any" ]
},
vanthome
  • 4,816
  • 37
  • 44