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.

5
  • 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( )); Commented Jun 4, 2016 at 8: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. Commented Jun 6, 2016 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. Commented Jun 7, 2016 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. Commented Jun 7, 2016 at 21:14
  • Hi, humm.. it looks like you're missing basic concepts of javascript, please check this sources and you'll possibly understand: stackoverflow.com/questions/1828924/… eloquentjavascript.net/04_data.html Commented Jun 7, 2016 at 21:30

1 Answer 1

0

An array of any typed values did the trick:

"mmeasures": {
  "type": [ "any" ]
},
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.