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
6
votes
2 answers

@JsonIgnore serialising Scala case class property using Jackon and Json4s

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 @JsonIgnoreProperties(Array("property_name")) to the case…
Alastair
  • 1,669
  • 3
  • 14
  • 27
6
votes
2 answers

Select between under_score and camelCase format with json4s

How can I map a json with underscore to a camelCase field in a case class? import org.json4s.jackson.JsonMethods.parse import org.json4s.DefaultFormats object Testing { implicit val formats = DefaultFormats.withBigDecimal def test = { val…
Neuquino
  • 11,580
  • 20
  • 62
  • 76
6
votes
2 answers

Importing .jar files into Scala environment

Even after reading: Scala, problem with a jar file, I'm still a bit confused. I am trying to import some packages into my Scala file, and the interpreter is not recognizing them even after adding to classpath. One example: I have the import…
Alex Spangher
  • 977
  • 2
  • 13
  • 22
6
votes
2 answers

How do you create Json object with values of different types?

How do you create Json object with values of different types ? I'm using spray-json Here is the code val images : List[JsObject] = fetchImageUrls(url).map((url: String) => { JsObject(List( "link_path" -> JsString(url), …
expert
  • 29,290
  • 30
  • 110
  • 214
5
votes
3 answers

Json4s not serializing Java classes

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.json4s" %% "json4s-jackson" % "4.0.5" though I have also tried with the 3.6.7…
juan2raid
  • 1,606
  • 1
  • 18
  • 29
5
votes
1 answer

Convert JValue to JSON string

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._ object Json4sTest { def main(arg:…
Bhaskar Mishra
  • 3,332
  • 7
  • 26
  • 36
5
votes
1 answer

Json4s ignores @JsonProperty jackson annotations

I have this code import com.fasterxml.jackson.annotation.JsonProperty import org.json4s.DefaultFormats import org.json4s.jackson.Serialization.{read, write} object Testing extends App { implicit val formats = DefaultFormats val json = …
Mikel San Vicente
  • 3,831
  • 2
  • 21
  • 39
5
votes
3 answers

How do I set Jackson parser features when using json4s?

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?
arosca
  • 469
  • 7
  • 15
5
votes
0 answers

deserializing mongo document's DateField into java.util.Date

I'm using mongo-scala combination in one of my new projects and it requires deserializing a mongo document with date field mongo document example { "_id" : ObjectId("56603577616e082f559da3d9"), "type" : "rule", "startTime" :…
Rohit
  • 1,878
  • 19
  • 26
5
votes
2 answers

Spark streaming + json4s-jackson dependency problems

I am unable to use json4s-Jackson 3.2.11 within my spark 1.4.1 Streaming application. Thinking that it was the existing dependency within the spark-core project that is causing the problem as explained here -> Is it possible to use json4s 3.2.11…
Gillespie
  • 2,228
  • 2
  • 18
  • 25
5
votes
1 answer

Scala json4s sealed trait as enums

We have our status defined as: sealed trait Status case object Status { case object StatusA extends Status case object StatusB extends Status case object StatusC extends Status } Our status looks like: val status = Status.StatusA Is there…
zmeda
  • 2,909
  • 9
  • 36
  • 56
5
votes
1 answer

Problems converting JSON objects in Scala

I'm trying to make a simple example of a class serialization in Scala using json4s library, but even after extensively searching for it on the internet, unfortunately I couldn't find any satisfatory sample that would solve my problem. Basically I…
blzn
  • 342
  • 1
  • 3
  • 15
5
votes
3 answers

json4s jackson - How to ignore field using annotations

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) Following code is not…
Jae-Ung Lim
  • 93
  • 1
  • 4
5
votes
3 answers

Is it possible to use json4s 3.2.11 with Spark 1.3.0?

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 spark-submit my JAR it provides me with…
5
votes
1 answer

Getting a field in Scala json4s

How do I get a particular field out of a Json object in Scala? I feel like I'm going in circles. import org.json4s._ import org.json4s.jackson.JsonMethods._ val me = parse(""" {"name":"brian", "state":"frustrated"} """) Now I want just the state.…
Brian Dolan
  • 3,086
  • 2
  • 24
  • 35
1 2
3
29 30