I got json like {"name":"susan","age":25},and a hint to json keyset like "name:String,age:Int",how to create a HList from that json?
How to convert JSON to scala shapeless.hlist?
348 Views Asked by xrz At
1
There are 1 best solutions below
Related Questions in SCALA
- Spark .mapValues setup with multiple values
- Where do 'normal' println go in a scala jar, under Spark
- Serializing to disk and deserializing Scala objects using Pickling
- Where has "Show Type Info on Mouse Motion" gone in Intellij 14
- AbstractMethodError when mixing in trait nested in object - only when compiled and imported
- Scala POJO Aggregator Exception
- How to read in numbers from n lines into a Scala list?
- Spark pairRDD not working
- Scala Eclipse IDE compiler giving errors until "clean" is run
- How to port Slick 2.1 plain SQL queries to Slick 3.0
- Log of dependency does not show
- Getting unary error for escaped characters in Scala
- Akka actor invoked with a function delegate - is this bad practice?
- Json implicit format with recursive class definition
- How to create a executable jar reading files from local file system
Related Questions in REFLECTION
- Serializing TypeInfo / Type across .Net Platforms
- C# check if there is an overload method with the specific type
- instantiating a generic class data type known at runtime
- Instantiate a class which implements a generic interface
- C# Activator.GetInstance instances don't retain state when created as Interfaces
- How to force others to obey a specific layout for a child class?
- How should I be using LambdaMetaFactory in my use case?
- Get full path of a package situated in source folder from junit
- instantiating a generic referance class with data types known at runtime
- How to create a Dynamic IEnumerable
- Swift reflection - How to check if a reflected value is a kind of type
- GetTypeInfo Performance in Windows Store Apps
- What's the difference or relationship between Type and TypeInfo?
- Deserializing Generic Types from a ClassLouder class with GSON
- Need to print function's actual parameter name used while calling
Related Questions in APACHE-FLINK
- How to flatMap a function on GroupedDataSet in Apache Flink
- Flink error - org.apache.hadoop.ipc.RemoteException: Server IPC version 9 cannot communicate with client version 4
- Output of Join in Apache Flink
- Flink Python API Bug
- OutOfBoundsException with ALS - Flink MLlib
- Apache Flink - use values from a data stream to dynamically create a streaming data source
- Flink-CEP use of hashCode and equals
- Flink: NoClassDefFoundError when runnig a Table API query
- Flink Avro Parquet Writer in RollingSink
- Apache Flink read Avro byte[] from Kafka
- Fetching first-n elements from multiple sorted partitions
- Flink error: java.lang.NoSuchMethodError: org.apache.flink.api.table.Table
- Flink Error: java.lang.ClassNotFoundException: org.apache.flink.shaded.calcite.com.google.common.base.Throwables
- Getting ClassNotFound Exception in Flink SourceFunction
- How to use Flink with Kafka 0.10.1.0?
Related Questions in SHAPELESS
- HList with unary constrain to varargs cast
- Passing a shapeless extensible record to a function (never ending story?
- Implicit Generic.Aux missing on conversion from Shapeless HList to case class
- Is there a way to extend type declarations?
- Convert a List[String] to a case class using Shapeless
- can Shapeless a good resource for extend properties in a request object finagle Service
- Pattern Match on Coproduct?
- Type safe type combinations with shapeless
- Is Shapeless' type inequality buggy?
- Generic[A] where A is a Class?
- copy method and subtype polymorphism in Scala
- Generic#to, but with Field Names?
- Is the a way to warn about unused values with decoding in Circe ?
- how to retrieve and inject sections from and to JSON
- How to extract an element from an HList with a specific (parameterized) type
Related Questions in HLIST
- Fold over a heterogeneous, compile time, list
- Autocheck children items in Tix with Python using CheckList and Hlist
- Putting out the Bonfire of the Arities with Shapeless?
- Is there a boilerplate-free way to convert HLists to an argument list?
- HList : String to Label
- Inferred type of function that zips HLists
- How can I use the new Slick 2.0 HList to overcome 22 column limit?
- type erasure in a poly function, scala
- Constrained heterogeneous list
- Basic Haskell monomorphism/polymorphism question (HList)
- Extractor for a shapeless HList that mimics parser concatenation `~`
- Applying validation from HList to a case class
- How to convert JSON to scala shapeless.hlist?
- Split list of algebraic date type to lists of branches?
- HList Ops - how are type classes constracted?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Based on the code you added and then deleted, it seems, having a runtime-string hint
"name:String,age:Int"and runtime-string json{"name":"susan","age":25}, you want to get anHListwith runtime reflection. You can do this as followsPlease notice that you do everything at runtime so you'll have no access to type
String :: Int :: HNilat compile time andhlisthas static type justHList(notString :: Int :: HNil) andHListis actually not better than justList[Any].build.sbt
Actually, I guess we do someting strange. We use highly type-level libraries (shapeless, circe) aimed to static type safety and then run them at runtime with reflection ignoring type safety and getting actually
List[Any](HList).I guess that if
List[Any](list of field values) is enough for you then you just need to use a more runtime library. For example, with json4sbuild.sbt
Actually the same can be done with Circe, just with
parseinstead ofdecode[A]If you need an instance of case class or a tuple rather than
HListreplacewith
or
correspondingly.