jerkson

Scanning a HUGE JSON file for deserializable data in Scala

走远了吗. 提交于 2020-01-12 05:24:28
问题 I need to be able to process large JSON files, instantiating objects from deserializable sub-strings as we are iterating-over/streaming-in the file. For example: Let's say I can only deserialize into instances of the following: case class Data(val a: Int, val b: Int, val c: Int) and the expected JSON format is: { "foo": [ {"a": 0, "b": 0, "c": 0 }, {"a": 0, "b": 0, "c": 1 } ], "bar": [ {"a": 1, "b": 0, "c": 0 }, {"a": 1, "b": 0, "c": 1 } ], .... MANY ITEMS .... , "qux": [ {"a": 0, "b": 0, "c"

Parsing JSON with multiple tuples to List<object> in scala

帅比萌擦擦* 提交于 2019-12-25 06:39:05
问题 [ {"fname":"Foo","lname":"Pacman"}, {"fname":"Bar","lname":"Mario"}, {"fname":"Poo","lname":"Wario"} ] Well I have JSON string in this format, Now what I need is to convert each tuples -> {"fname":"Foo","lname":"Pacman"} To a Person object, for e.g. lets assume I have a case class case class Person(fname:String,lname:String) Now how am I to get, List<person> If I had a JSON containing data for single tuple, then I could, val o:Person = parse[Person](jsonString)// I am actually using Jerkson

Custom json serialization of structured scala case classes

别说谁变了你拦得住时间么 提交于 2019-12-06 02:19:28
问题 I have some working jackson scala module code for roundtripping scala case classes. Jackson worked great for flat case classes but when I made one which contains a list of other case classes the amount of code I seemed to need was a lot. Consider: abstract class Message case class CardDrawn(player: Long, card: Int, mType: String = "CardDrawn") extends Message case class CardSet(cards: List[CardDrawn], mType: String = "CardSet") extends Message To get the CardSet to roundtrip to/from json with

Custom json serialization of structured scala case classes

 ̄綄美尐妖づ 提交于 2019-12-04 07:31:27
I have some working jackson scala module code for roundtripping scala case classes. Jackson worked great for flat case classes but when I made one which contains a list of other case classes the amount of code I seemed to need was a lot. Consider: abstract class Message case class CardDrawn(player: Long, card: Int, mType: String = "CardDrawn") extends Message case class CardSet(cards: List[CardDrawn], mType: String = "CardSet") extends Message To get the CardSet to roundtrip to/from json with jackson scala module I used a custom serializer/deserializer written in java: object

Scanning a HUGE JSON file for deserializable data in Scala

做~自己de王妃 提交于 2019-12-03 07:13:43
I need to be able to process large JSON files, instantiating objects from deserializable sub-strings as we are iterating-over/streaming-in the file. For example: Let's say I can only deserialize into instances of the following: case class Data(val a: Int, val b: Int, val c: Int) and the expected JSON format is: { "foo": [ {"a": 0, "b": 0, "c": 0 }, {"a": 0, "b": 0, "c": 1 } ], "bar": [ {"a": 1, "b": 0, "c": 0 }, {"a": 1, "b": 0, "c": 1 } ], .... MANY ITEMS .... , "qux": [ {"a": 0, "b": 0, "c": 0 } } What I would like to do is: import com.codahale.jerkson.Json val dataSeq : Seq[Data] = Json