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

Writing a Tuple2Serializer for json4s

I am having trouble turning my data into nested JSON objects. My current data looks like this: Map(23 ->…
theMadKing
  • 2,064
  • 7
  • 32
  • 59
0
votes
0 answers

Corresponding value in json document

Suppose I have 2 json documents of similar structure: A. {"a:"{"b": 42}} B. {"a":{"b": 1}} My task is to find corresponding path in first document while having path of second document. For example, let find the diff of these 2 docuemnts: A diff…
maks
  • 5,911
  • 17
  • 79
  • 123
0
votes
0 answers

How to use Double instead of Long in JsNumber in Play Framework (json4s)?

I am using Play Framework's WS API to make requests to a certain service. The service misbehaves if we send integers instead of doubles in JSON POST requests. Even if we want to send { "value" : 2 }, it would rather accept { "value" : 2.0 }. Is…
chbh
  • 336
  • 2
  • 13
0
votes
2 answers

Json4s serialisation of superclass

I'm having trouble writing a custom serialiser for Json4s to handle the following situation. I have case classes: trait Condition case class BasicExpression (field:String, operator:String, value:String) extends Condition case class BooleanExpression…
0
votes
0 answers

json4s query on a parsed spark json stream

I am trying to use the json4s to parse and query through a stream in spark. I can parse the stream to org.apache.spark.streaming.dstream.DStream[org.json4s.JValue]. But when I try to use the query feature I seem to fail at browsing using "\\". Below…
etr
  • 1,252
  • 2
  • 8
  • 15
0
votes
1 answer

Deserializing complex JSON of Polymorphic Lists

I have a JSON file that looks like this: { "Animals": [ [ 543, "Mammals", [ 1, "Cat", 22, 45, 18 ], …
nietsnegttiw
  • 371
  • 1
  • 5
  • 16
0
votes
1 answer

Converting (Very) Complicated JSON objects to Scala Objects With Case Classes In Json4s

I have a very complicated JSON file that looks like this: { "Animals": [ [ 100, "Mammals", [ 1, "Cat", …
nietsnegttiw
  • 371
  • 1
  • 5
  • 16
0
votes
1 answer

Accessing a Single Value from Parsed JObject in Scala (Jackson, json4s)

I have an object like this: val aa = parse(""" { "vals" : [[1,2,3,4], [4,5,6,7], [8,9,6,3]] } """) I want to access the value '1' in the first JArray. println(aa.values ???) How is this done? Thanks
nietsnegttiw
  • 371
  • 1
  • 5
  • 16
0
votes
1 answer

Getting Exception while converting case class to Json using Json4s

I am trying to convert a case class to Json String using Json4s. I am getting the exception MappingException: Can't find ScalaSig for class java.lang.Object This is happening if I am extending my case class with another trait only. My code is as…
Yadu Krishnan
  • 3,492
  • 5
  • 41
  • 80
0
votes
2 answers

How can I strip out empty/invalid fields from json when using Json4s?

If I have the following: object Json4sTest extends App { val info = new TestObject("Johnny", "USA") println(info) } case class TestObject( name: String, companyName: String, var countryCode: Option[String] = None, var countryName:…
iCodeLikeImDrunk
  • 17,085
  • 35
  • 108
  • 169
0
votes
0 answers

Automatize json objects creation from Array

I am trying to automatize the creation of a json object from an ArrayBuffer[Array[String]](), where I have the field and its value saved, to throw it into a database (mongodb). I can't find a way to do that. I am using scala and json4s. Would anyone…
wipman
  • 581
  • 6
  • 22
0
votes
0 answers

Where to define the implicit val formats in a microservice with Scala, akka-http, Json4s?

I am building a microservice using Scala, akka-http, json4s. Also using case classes for my business bean classes. My case classes have scala Enumerations (I researched on the scala Enums and aware of the limitations, but this perfectly suits my…
Phani
  • 1,851
  • 2
  • 15
  • 28
0
votes
1 answer

How to deserialize json without index with json4s

Using json4s, what is best practice to deserialize JSON to Scala case class (without index-key)? some.json { "1": { "id": 1, "year": 2014 }, "2": { "id": 2, "year": 2015 }, "3": { "id": 3, "year": 2016 } } some…
sh0hei
  • 51
  • 6
0
votes
1 answer

Scala Play Framework JSON JsNull using json4s

I'm new to Scala. How do I handle the JsNull value in my code? I'm using json4s to convert the JSON to a map. Should I somehow be converting JsNull to an Option? Example: Play JSON : creating json val jsonA: JsValue = Json.obj( "name" ->…
krzasteka
  • 427
  • 1
  • 4
  • 14
0
votes
1 answer

Accessing inner JSON field in Scala

I have JSON string as { "whatsNew" : { "oldNotificationClass" : "WhatsNewNotification", "notificationEvent" : { ..... }, "result" : { "notificationCount" : 10 ..... } }, ...... "someEmpty": { }, ...... } I am…
αƞjiβ
  • 3,056
  • 14
  • 58
  • 95