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

json4s noSuchMethodError when querying deployed engine in predictionIO

I have a data stack built around PredictionIO 0.14. I use ES 6.4.2, spark2.4.3, and scala 2.11.12(because spark 2.4.3 is back to scala 2.11 as default). I manage to do pio build, pio train, and pio deploy. I'm able to see the engine info if I open…
0
votes
2 answers

Parse Complex JSON -- Map

I need to parse the complex JSON (below) IN SCALA to get the values of "expression" and "value" in "measure" key i.e I need List (COUNT, COUNT_DISTINCT ...) and List (1,tbl1.USER_ID ...). I tried multiple options, but it is not working. Any help is…
CSUNNY
  • 414
  • 1
  • 7
  • 23
0
votes
1 answer

json4s "Can't convert JString(2019-04-28T01:23:45.678Z) to class java.time.Instant"?

I'm struggling to get json4s to work with java.time.Instant values in my case class. The REPL looks like this. scala> case class TestTime(tag: String, t: java.time.Instant) defined class TestTime scala> import org.json4s._ import…
Bob Kuhar
  • 10,838
  • 11
  • 62
  • 115
0
votes
1 answer

Scala generics usage for methods + json4s parsing

I am not sure if this is achievable and I have a very basic understanding of how generics work in scala. But I was wondering if this is possible. Say I have a method: case class Person(id:String,name:String) case class Student(id:String,name:String,…
Achilleus
  • 1,824
  • 3
  • 20
  • 40
0
votes
1 answer

json4s, "no implicit view available from List of case class to JValue" when attempting to combine

I try to generate json by combining some fields, including a Seq of case class. import org.json4s._ import org.json4s.JsonDSL._ import org.json4s.jackson.JsonMethods._ import org.json4s.jackson.Serialization import…
papahugo
  • 41
  • 1
  • 2
0
votes
1 answer

ObjectIds don't get retrieved from collection (Scala + MongoDB)

There is a MongoDB instance on my computer with a database. A couple of documents are present in one of the collections, I inserted them manually. There is a Scala application to manipulate the database. There is a case class called Location. case…
BPetike
  • 83
  • 13
0
votes
1 answer

Extracting nested serialized json with json4s into case classes in Scala

I am attempting to parse the following Json with json4s in Scala, but I cannot due to the nested structure: [ { "body":"8", "start":29, "value":{ "value":8, "type":"value" }, "end":30, "dim":"number", …
Chris
  • 99
  • 1
  • 1
  • 14
0
votes
1 answer

How to deserialize a scala tree with JSON4S

Serialization works fine but I have nothing for deserialization. I found interesting solution for abstract class here How to serialize sealed abstract class with Json4s in Scala? but it doesn't deal with trees. This the code of my test with a…
user10932128
0
votes
1 answer

Extract a map from a Json interprets all numbers as BigInt

i've extracted a map from json. This works so far. As I don't know before parsing which fields are there in the json, I've been using a Map[String, Any]. Every field only consisting of digits is interpreted as a BigInt, which I don't want. MyCode: …
ScalaNewbie
  • 173
  • 3
  • 12
0
votes
1 answer

Create empty object in JSON via Json4s DSL

The JSON documents I'm creating need to have a properties field, even if there are no properties. {"foo":"bar","properties":{}} is legal, {"foo":"bar"} is illegal. How can I define an empty object to use as the properties value using the Json4s…
Synesso
  • 37,610
  • 35
  • 136
  • 207
0
votes
0 answers

Unable to deserialize parameter "jsonClass" using Json4s

I have a json which looks like this var cutJson = """ |{ | "routingKey": "event.orders.status.paid", | "jsonClass" : "Event" |} """.stripMargin[enter image description here][1] I aim to decerialize it and construct scala object.…
0
votes
1 answer

json4s: cross field extraction

json4s extract JsonAST based on per-type rules defined in DefaultFormats and CustomSerializer. Sometimes I want to have cross field extraction. For example, given a json string {"a": 1, "b": 2}, I want to set the value of b into a+b. I can…
yiksanchan
  • 1,890
  • 1
  • 13
  • 37
0
votes
1 answer

scala json parse and get a nested key and value

I have a json like below, I have json like below I need to extract the value from them { "filed1": "value1", "message": { "payload": [{ "type": ["Extra","ID"], info": { "value": 8 …
0
votes
0 answers

How to make a nested Map from an scala List

I have an scala List like this: List((List("android..", "android.webkit.*", "android.webkit.WebView"),List("void setInt (int), 20", "boolean deleteCache (android.content.Context), 20"))) From the above List I need something like the following…
Yasir Arefin
  • 351
  • 1
  • 9
  • 23
0
votes
1 answer

Deserialize NaN, Infinity using Json4s

Need to convert NaN in Json(as it is not JSON) to Double in Json4s without using jackson. For example, I am having following JSON: { "a": NaN } I need to parse above json using JSON4S. Can we write any deserializer if possible for this?
Devavrata
  • 1,785
  • 17
  • 30