I want to create data that have a form of List[DenseVector[Double]] using scala and Breeze library. The initial data are loaded with json4s, so they have a form of List(Jarray(JDouble) does anyone have any idea ?
Asked
Active
Viewed 38 times
0
-
BEWARE: [json4s is vulnerable under DoS/DoW attacks!](https://github.com/json4s/json4s/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+denial) – Andriy Plokhotnyuk Jul 04 '22 at 08:34
1 Answers
0
Yes, you can use this code:
list
.map { case JArray(list) => list.map { case JDouble(v) => v } }
.map(el => DenseVector(el))

Emiliano Martinez
- 4,073
- 2
- 9
- 19
-
thank you, I found out by using `.map(x=>x.children).map(x=>DenseVector(x.map(y=>y.extract[Double]):_*)) ` – Reda20 Mar 18 '22 at 08:53