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
0 answers

Why there is a error when I use org.json4s.jackson.Serialization.write from spark

This is my first time use scala and spark. I use this code to extract data. I extracted successfully. If I don't use println(write(output1)) but use println(output1), the code runs well and did print the correct output without keys. But when I use…
0
votes
1 answer

What can be done about "Compiler synthesis of Manifest and OptManifest is deprecated"

json4s version 4.0.3 scala version 3.1.0 jdk version 1.8.0_181 Does everyone else get warnings like this? Is there a way to suppress or work around them? [warn] -- Deprecation Warning: ...\serialization\json\JSONSerializer.scala:76:51 [warn] 76 | …
0
votes
1 answer

How I can sort list of JObject (Scala, json4s)

I read a JSON file and use json4s to parse JSON. How I can sort an array of JObject that I read from the file? package org.example import org.json4s._ import org.json4s.native.JsonMethods._ object Main extends App { val file =…
0
votes
0 answers

JSON Object Property with space in Scala using Json4s(Jackson)

I have a JSON String in the given below form: var jStr = """ { |"company":{ |"company name":"ABCD" |}, |"person":[ |{"name":"john", |"age":"28" |}, |{ |"name":"AWQ", |"age":"45" |} |] |} """.stripMargin See the property…
0
votes
1 answer

Scala - How to extract Json4s with dynamic case class created with ToolBox

I defined the case class dynamically using Toolbox. And when I do extract of json4s, I get the following exception: import org.json4s._ import scala.reflect.runtime._ import scala.tools.reflect.ToolBox implicit val formats =…
0
votes
1 answer

json4s used in scalatra application throws "com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input"

json4s used in scalatra application throws "com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input" when a POST request through a browser. I have a ScalatraServlet to serve FORM submit from browser. Here is the…
nashter
  • 1,181
  • 1
  • 15
  • 33
0
votes
0 answers

How do i convert a JArray[String] to Scala List

I am struggling to convert a Jarray[JString] to Scala List[String] scala> (configMap \ "orderedCols").extract[JArray] res27: org.json4s.JArray = JArray(List(JString(id), JString(name))) scala> (configMap \ "orderedCols").extract[JArray].toList …
Surender Raja
  • 3,553
  • 8
  • 44
  • 80
0
votes
1 answer

Serialization.read() is not "found" inside a map block [Scala]

I'm using json4s for dealing with Json responses from http responses. I was earlier using Await but I'm now switching to use Future. I have a function like: executeRequest(): Future[Response[String]] and another function like: def getAccessToken()…
Saturnian
  • 1,686
  • 6
  • 39
  • 65
0
votes
0 answers

json4s throws NoClassDefFoundError: java/sql/Timestamp

When following the json4s instructions on Serialization I keep getting the followinng error: java.lang.NoClassDefFoundError: java/sql/Timestamp at org.json4s.reflect.Reflector$.(Reflector.scala:22) at…
Ramón J Romero y Vigil
  • 17,373
  • 7
  • 77
  • 125
0
votes
1 answer

HowTo skip deserialization for a field in json4s

Here is my json: { "stringField" : "whatever", "nestedObject": { "someProperty": "someValue"} } I want to map it to case class MyClass(stringField: String, nestedObject:String) nestedObject should not be deserialized, I want json4s to leave it…
Capacytron
  • 3,425
  • 6
  • 47
  • 80
0
votes
0 answers

json4s first serialization taking abnormally long time

I use the json4s library in many projects, and I recently noticed a weird behavior that I'm not able to explain while debugging some unit tests. The issue is quite simple: when serializing a case class into a string, the first serialization…
Thundzz
  • 675
  • 1
  • 11
  • 15
0
votes
1 answer

How to implement a CustomKeySerializer

If I try to serialize the case class: case class C(map: Map[Boolean, String]) I get the exception: org.json4s.package$MappingException: Do not know how to serialize key of type class java.lang.Boolean. Consider implementing a CustomKeySerializer I…
user79074
  • 4,937
  • 5
  • 29
  • 57
0
votes
3 answers

Serializing a case class with a lazy val causes a StackOverflow

Say I define the following case class: case class C(i: Int) { lazy val incremented = copy(i = i + 1) } And then try to serialize it to json: val mapper = new ObjectMapper() mapper.registerModule(DefaultScalaModule) val out = new…
user79074
  • 4,937
  • 5
  • 29
  • 57
0
votes
1 answer

How can I configure Spring to use Json4s to serialize response bodies?

I'm using Spring Boot in a Scala project, and I already use Json4s for serializing & deserializing JSON. Up until now, I've been writing endpoints like this: @RequestMapping(path = Array("/getSomething"), produces =…
Ian
  • 5,704
  • 6
  • 40
  • 72
0
votes
0 answers

Can't find ScalaSig

I'm trying to complete http request using RequestContext.complete and Promise[RouteResult], but i'm getting an error: org.json4s.package$MappingException: Can't find ScalaSig for class…
HudsonHornet
  • 89
  • 1
  • 9