These are chat archives for chandu0101/scalajs-react-components

1st
Mar 2016
elyphas
@elyphas
Mar 01 2016 16:42
How can I convert from Vector[case class ] to json, I got my data in this format, but ReactTable needs json??
elyphas
@elyphas
Mar 01 2016 16:56
sorry, I think I was confuse, I need the Vector to Map,
elyphas
@elyphas
Mar 01 2016 17:59
in fact more precise: Vector -> Vector[Map[String, Any]]; :) sorry.
Otto Chrons
@ochrons
Mar 01 2016 18:35
you should create a facade for ReactTable, then you have compatible data objects
I am in troubles with "data" with type Vector[Map[String, Any]]
Carlos Quiroz
@cquiroz
Mar 01 2016 18:43
I’m guessing you cannot serialize a Map[String, Any]
Because there is not an Any serialization
elyphas
@elyphas
Mar 01 2016 18:44
yes, that's the problem
Carlos Quiroz
@cquiroz
Mar 01 2016 18:44
you may need to restrict your type
elyphas
@elyphas
Mar 01 2016 18:45
@cquiroz ; I am trying to use this: https://gist.github.com/lauris/7dc94fb29804449b1836
Otto Chrons
@ochrons
Mar 01 2016 18:49
there's no need to serialize anything for the ReactTable, since it's Scala code
elyphas
@elyphas
Mar 01 2016 18:50
@ochrons , @cquiroz ; then I can use the code above to convert from Vector[Articulo] to Vector[Map[String, Any]]?
  • can I use
Otto Chrons
@ochrons
Mar 01 2016 18:52
looks like it's using reflection, which doesn't work in Scala.js
elyphas
@elyphas
Mar 01 2016 18:53
ok, thank, then need another way, :worried:
Otto Chrons
@ochrons
Mar 01 2016 18:53
for generic manipulation like this there's the shapeless library
it's a bit complicated, but it can convert from case classes to HLists etc.
Carlos Quiroz
@cquiroz
Mar 01 2016 18:54
There are many ways to convert your data to json
upickle, circe, etc
But you’d need to restrict your type
Otto Chrons
@ochrons
Mar 01 2016 18:54
JSON is not the issue here :)
this is about expanding a case class to a Map(fieldName -> fieldValue)
Carlos Quiroz
@cquiroz
Mar 01 2016 18:55
I see
Otto Chrons
@ochrons
Mar 01 2016 18:55
anyway, if you don't have a huge number of case classes, you should just write a conversion function yourself
elyphas
@elyphas
Mar 01 2016 18:57
@ochrons ; I tried that first; "("cve"->item.cve,"descrip"->item.descrip).toMap, doesn't works
elyphas
@elyphas
Mar 01 2016 19:07
I think this could works, I am going to try: Map( "fname"->item.CveArticulo, "lname"->item.Descripcion, "email"->item.CveArticulo, "contry"->item.Descripcion )
yes, it works.
Otto Chrons
@ochrons
Mar 01 2016 19:11
as simple as that :)
elyphas
@elyphas
Mar 01 2016 19:11
:)
@ochrons ; thanks you for all.