json4s Questions

3

I have some scala code that needs to be able to serialize/deserialize some Java classes using Json4s. I am using "org.json4s" %% "json4s-ext" % "4.0.5" and "org.j...
Spencerspencerian asked 10/5, 2022 at 17:43

3

I am receiving the following error while attempting to parse JSON with json4s: Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow How do I enable this feature...
Italia asked 24/8, 2016 at 21:36

3

I`m using json4s-jackson(version 3.2.11). I'm trying to ignore field using annotations(like jackson java version). Here's exmaple: case class User(id: Long, name: String, accessToken: String) ...
Weisbrodt asked 27/3, 2015 at 8:35

1

I have a case class with many members, two of which are non-primitive: import com.twitter.util.Duration case class Foo( a: Int, b: Int, ..., y: Int, z: Int, timeoutSeconds: Duration, runtim...
Bridgework asked 29/11, 2014 at 4:35

8

Solved

Is there a simple way to converting a given Row object to json? Found this about converting a whole Dataframe to json output: Spark Row to JSON But I just want to convert a one Row to json. Here...
Allusion asked 11/1, 2017 at 22:28

2

How to easily rename field-names in json4s? From their documentation, i've tried the following snippet but it doesn't seem to rename the serial field to id. case class Person(serial: Int, firstNa...
Eme asked 11/2, 2014 at 0:13

1

Set up I'm using json4s 3.2.11 and Scala 2.11. I have an enumeration defined using sealed trait, and a custom serializer for it: import org.json4s.CustomSerializer import org.json4s.JsonAST.JStr...
Putnem asked 17/4, 2019 at 3:55

2

I am using Json4s classes inside of a Spark 2.2.0 closure. The "workaround" for a failure to serialize DefaultFormats is to include their definition inside every closure executed by Spark that need...
Ethnology asked 26/1, 2018 at 1:31

3

Solved

Basically, i have to analyze some complex JSON's on HDFS with Spark. I use "for comprehensions" to (pre)filter the JSON's and "extract" method of json4s to wrap it into a case class This one wor...
Rosenthal asked 16/7, 2014 at 16:49

0

Below is my sample JSON and can be nested to any level deep: { "key1": { "keyA": 'valueI' }, "key2": { "keyB": 'valueII' }, "key3": [ { "a":1, "b":2 }, { "a":1, "b":2 } ] } This ...
Knap asked 3/8, 2018 at 8:27

2

I've a strange problem with spark 2.1.1 and json4s.jackson. I upgraded my streaming project from spark 1.5.1. Now when I execute code in IDE everything works fine. But after assembly and code sta...
Vermination asked 24/7, 2017 at 7:11

2

Solved

The following test snippet implicit val formats = DefaultFormats + FullTypeHints(Contacts.classList) val serialized = Serialization.write(List(Mail(field = "[email protected]", note = "Rando...
Redintegration asked 19/10, 2017 at 15:55

2

Solved

This snippet of code works very well, but it generates compact JSON (no line breaks / not very human readable). import org.json4s.native.Serialization.write implicit val jsonFormats = DefaultForma...
Beyrouth asked 24/8, 2016 at 15:8

1

I have a really simple example: import org.json4s._ import org.json4s.native.JsonMethods._ import org.json4s.JsonDSL._ val json = ("english" -> JString("serialization")) ~ ("japanese" -> JS...
Sewing asked 3/2, 2016 at 4:20

1

I want to convert a jvalue to json string. Here is what my code look like: import org.json4s._ import org.json4s.JsonDSL._ import org.json4s.native.JsonMethods._ import org.json4s.DefaultFormats._...
Ovum asked 17/3, 2017 at 11:11

2

I'm trying to prevent one of the properties of a Scala case class being serialised. I've tried annotating the property in question with the usual @JsonIgnore and I've also tried attaching the @Json...
Christhood asked 3/9, 2014 at 22:48

2

Solved

I am currently extracting some metrics from different data sources and storing them in a map of type Map[String,Any] where the key corresponds to the metric name and the value corresponds to the me...
Engdahl asked 8/1, 2015 at 14:52

2

I have a nested json whose structure is not defined. It can be different each time I run since I am reading from a remote file. I need to convert this json into a map of type Map[String, Any]. I tr...
Earmark asked 28/4, 2015 at 0:33

2

Solved

I've run into an issue with attempting to parse json in my spark job. I'm using spark 1.1.0, json4s, and the Cassandra Spark Connector. The exception thrown is: java.io.NotSerializableException: ...
Hame asked 15/4, 2015 at 22:36

2

Solved

I'm having a problem very similar to what's described here: Combining type and field serializers case class(id: Option[UUID], otherValue:String, … ) The answer to the related question would allo...
Mondragon asked 1/6, 2014 at 7:48

2

Solved

I have a sample array: [{ "abc":"1", "de":"1" }, { "fgh":"2", "ij":"4" }] which is a org.json4s.JsonAST.JValue. How is it possible to iterate over each object inside the array, to operate o...
Boxthorn asked 20/1, 2016 at 11:36

2

In the example given on the json4s readme https://github.com/json4s/json4s#serializing-non-supported-types the match only works if the fields are order {"start":0,"end":0}. If the start and end fie...
Makell asked 24/7, 2014 at 20:50

1

Solved

I have a common problem but still couldn't wrap my head around what I was reading around. In a scalatra app, I am receiving the following json: { _type: "hello", timestamp: 123, data: [ {table: "...
Eared asked 29/10, 2015 at 11:35

2

Solved

I have some case classes defined like follows: sealed trait Breed case object Beagle extends Breed case object Mastiff extends Breed case object Yorkie extends Breed case class Dog(name: String, ...
Paul asked 14/10, 2015 at 21:27

3

Spark has a dependency on json4s 3.2.10, but this version has several bugs and I need to use 3.2.11. I added json4s-native 3.2.11 dependency to build.sbt and everything compiled fine. But when I sp...
Crimpy asked 23/3, 2015 at 17:35

© 2022 - 2024 — McMap. All rights reserved.