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
1
vote
1 answer

Serialization of case classes extending Seq-Trait

It looks like when I try to serialize a case class extending from Seq it gets handeled as a Seq and all additional fields are omitted. Serializing just leads to a Standard Sequence without the additional fields. Whereas deserialization…
Andreas Neumann
  • 10,734
  • 1
  • 32
  • 52
0
votes
1 answer

How to add element into a nested array using json4s with Scala

I have the following json String: val jsonMessage: String = """{ | "code": "OK", | "idEvent": "123", | "contract": { | "idApplication": "001" | }, | "version": { | "idVersion": "1", | …
Mamaf
  • 345
  • 4
  • 10
0
votes
0 answers

SCALA-JSON: How can I manipulate a json to send a json object into 2nd level nested object?

I want to send a main JSON object named testId into 2 level nested json objects like the example below (inside ALTIMETER and WEIGHT). How can i reach the After Json below by using Below Json in Scala? In the internet, I saw that I should use json4s…
bbgghh
  • 79
  • 1
  • 2
  • 9
0
votes
0 answers

Json4s with not printing escape character in string

I got stuck in printing(writing) string with Json4s JField. Simply my situation is like that case class Sample( name: String, value: String ) val doc = Seq(Sample("name", "John\\s"),…
Javier Kim
  • 13
  • 3
0
votes
1 answer

How to know which field is missed while parsing json in Json4s

I have made a generic method which parses json to case class and it also works fine. But if tries to parse big json which have one or two mandatory field then I am not able to figure out which particular mandatory f ield is missing. I am only able…
0
votes
1 answer

How to parse arbitrary protobuf message in scala usind scalapb

According to the documentation scalapb is able to parse arbitrary protobuf messages into json format. However, I cannot make heads or tails of their documentation and my code simply does not compile: // apparently the Companion Object provides the…
Sim
  • 4,199
  • 4
  • 39
  • 77
0
votes
1 answer

How to convert Spark Dataframe to JSON using json4s, in Scala?

Trying to convert a dataframe to a JSON string and the output is just {}. Not sure what I'm doing wrong? This is just a test but full Dataframe schema I need to use is 800+ columns so I don't want to have to specify each field specifically in the…
Alex Kerr
  • 956
  • 15
  • 44
0
votes
1 answer

How to wrap org.json4s.JValue in org.asynchttpclient.Response

I'm refactoring some tests where previously the response was parsed into org.json4s.JValue I want to pass the response as type org.asynchttpclient.Response as input parameter. In order to distinguish the HTTP code status. NettyResponse and…
Raymond Chenon
  • 11,482
  • 15
  • 77
  • 110
0
votes
1 answer

Scala json4s Deserialization for the abstract trait causes MappingExeption: Unexpected type info RefinedType

My code contains the following entities: case class Source(uuid: String, `type`: String, parameters: Connector) sealed trait Connector case class Snowflake( val username: String, val password: String, val host: String, val role:…
eva93
  • 1
  • 2
0
votes
0 answers

scala json4s in for comprehension - cannot resolve symbol flatMap

I would like to use functions in for-comprehension with input/return values of type JValue, that is defined within json4s. The following snippet: def func1(...):org.json4s.JValue def func2(val1:org.json4s.JValue):... for { aJValue <- func1(...) …
bayerb
  • 649
  • 2
  • 9
  • 28
0
votes
1 answer

Parsing JObject In Scala

I am using json4s for parsing a json object which gives me result like this: JObject(List((x,JArray(List(JString(x_value)))), (y,JArray(List(JString(y_value)))), (z,JArray(List(JString(z_value)))))) Now I want to convert it like this: Map("x" ->…
0
votes
1 answer

Does anyone knows how to create a DenseVector[Double] using Breeze library in scala

I want to create data that have a form of List[DenseVector[Double]] using scala and Breeze library. The initial data are loaded with json4s, so they have a form of List(Jarray(JDouble) does anyone have any idea ?
Reda20
  • 53
  • 5
0
votes
1 answer

How to render JArray without square parentheses into JSON?

When I render JArray object: val json = compact(render(data)) I get JSON like that: [ {object}, {object} ] But I need to get next text data: {object}, {object} In other words, I need to get string without "open and end" square parentheses. Is…
0
votes
0 answers

How to concat two JArray with json4s in Scala?

I get data from REST API. I need to do a few request and concat array from each request into one Json. //getting body of response val json = parse(body) val data = json \ "data" //... //... other request of data val json_other =…
0
votes
1 answer

Scala parsing nested json with Json4s

I am trying to fetch data from nested JSON, I need only a few fields from the JSON, I have created case classes for the required data, the solution I found from google suggested to use read function, but I get an empty Object I tried to google with…