Questions tagged [json4s]

A single AST to be used by other scala json libraries

At this moment there are at least 6 json libraries for scala, not counting the java json libraries. All these libraries have a very similar AST. This project aims to provide a single AST to be used by other scala json libraries.

At this moment the approach taken to working with the AST has been taken from lift-json and the native package is in fact lift-json but outside of the lift project.

https://github.com/json4s/json4s

449 questions
0
votes
1 answer

Scala Parsing JSON behaving differently in a function

I am trying to create a function to parse my records and I am getting two different behaviors when I call a function vs hard coding it: I am using: import org.json4s.JsonAST.{JString, JField, JObject, JArray} import…
theMadKing
  • 2,064
  • 7
  • 32
  • 59
0
votes
2 answers

How to convert nested maps of type Map[String, Map[String, Any]] to JSON in Scala?

I tried converting Map[String, Map[String, Any]] in Scala to JSON but since they have nested maps so unable to do it. Is there a way to do it? I tried looking at this link but it converts everything to string and converts a list as "List(...)". Any…
0
votes
2 answers

Scala Json(json4s) parse return None

$ "properties": [ { "name": "Armour", "values": [ [ "258", 1 ] ], …
0
votes
1 answer

Scala Type Variances Error with JSON serializer in phantom-dsl with json4s

Am getting the following error for the below code. Any insights greatly appreciated. Not quite sure what is causing this as I have ample other User Defined Types throughout the application which have not caused this behaviour. Let me know if any…
dan-mi-sun
  • 551
  • 2
  • 4
  • 18
0
votes
1 answer

How to serialized generic class?

I have following case class case class UserId(value: String) extends MappedTo[String] (MappedTo is a generic id case class of slick.typesafe) and I declare its serializer in json4s case object IdSerializer extends CustomSerializer[UserId](format =>…
mmdc
  • 1,677
  • 3
  • 20
  • 32
0
votes
0 answers

json4s convert inherited class to json

I am trying to serialize / deserialize to json with json4s native the following case class : case class UserId(value: String) extends MappedTo[String] with Guid case class FootballTeamId(value: String) extends Guid trait Guid extends Id[String] with…
David Puleri
  • 144
  • 8
0
votes
1 answer

JSON serializer with json4s on phantom-dsl Collection column

Have been following the collection column tutorial for phantom-dsl which requires json serializer. The implementation below is getting the following error output; found : org.dyne.danielsan.superchain.data.models.JsonVin [error] required:…
dan-mi-sun
  • 551
  • 2
  • 4
  • 18
0
votes
1 answer

How to get rid of this implicit conversion?

Suppose I am using json4s to parse JSON: val str = """{"a":"aaaa", "x": 0}""" val json = JsonMethods.parse(str) val a = for(JObject(fields) <- json; JField("a", JString(a)) <- fields) yield a The type of a is List[String] but I need Option[String],…
Michael
  • 41,026
  • 70
  • 193
  • 341
0
votes
1 answer

How to test if the case classes I have created for the parser are correct using json4s libraries in scala?

I have a huge json object and I need to parse it and then write some tests to see if everything goes as expected. case class User(id: Identification, age:Int, name: String ...) case class Identification(id: Int, hash: String ....) ... a lot more…
lads
  • 1,125
  • 3
  • 15
  • 29
0
votes
1 answer

Json4S Recursive method parse needs a result type

I am using json4s library in my scala program. my build.sbt looks like libraryDependencies ++= Seq( "org.json4s" % "json4s-native_2.11" % "3.3.0" ) in my code, i have a function import org.json4s._ import org.json4s.native.JsonMethods._ import…
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
0
votes
1 answer

Deserializing JSON with JSON4S

I have JSON in following format: { "id": 1913548255, "notification": "NotificationReceived", "deviceGuid": "e60d6085-2aba-48e9-b1c3-73c673e414be", "timestamp": "2016-01-28T20:34:34.167", "parameters": { "jsonString":…
0
votes
1 answer

Generating json in this format using Scala

I have this String : "[[{\"cfunction\":\"sum\"},{\"cfunction\":\"groupBy\"}],[{\"cfunction\":\"Add Here\"}]]"; Which is generated by : val json2 = List(List(("cfunction" -> "sum"), ("cfunction" -> "groupBy")), List(("cfunction" -> "Add…
blue-sky
  • 51,962
  • 152
  • 427
  • 752
0
votes
1 answer

JSON deserializing in Spark with json4s causing package$MappingException

I am trying to deserialize a simple JSON to a case class in Spark but getting an exception - the same code works in regular environment. I am using the following version of json4s: "org.json4s" % "json4s-jackson_2.11" % "3.3.0" The code: import…
LK__
  • 6,515
  • 5
  • 34
  • 53
0
votes
1 answer

json4s and Joda Time

I am having difficulties with Joda time and json4s, the error I am getting is the following: Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/Manifest$ at…
theMadKing
  • 2,064
  • 7
  • 32
  • 59
0
votes
0 answers

json4s JDouble(NaN) writes to a string "NaN"

I am having an issue with json4s where it is picking up the JDouble(NaN) and when I do a write to json, Serialization.write(json) I am getting the output as a string in JSON "NaN" and it is causing conflicts when I am adding to records in my…
theMadKing
  • 2,064
  • 7
  • 32
  • 59