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

json4s object extraction with extra data

I'm using spray with json4s, and I've got the implementation below to handle put requests for updating objects... My problem with it, is that I first extract an instance of SomeObject from the json, but being a RESTful api, I want the ID to be…
JBarber
  • 212
  • 1
  • 7
0
votes
1 answer

trouble extracting recursive data structures in scala with json4s

I have a json format that consists of map -> map -> ... -> int for an arbitrary number of maps per key. The keys are always strings and the leaf types are always ints. The depth of the map structure varies per key in the map. For example, key "A"…
trent
  • 1
  • 1
0
votes
1 answer

Having trouble with implicit conversion in scala

Having this code case class Workspace(ident: Long, name: String) case class Project(ident: Long, name: String) implicit def workspaceJSON: JSONR[Workspace] = new JSONR[Workspace] { def read(json: JValue) = …
cvb
  • 337
  • 2
  • 8
0
votes
2 answers

(Un)marshall JSON with named root for Ember Data using Scala case class on Spray

I am writing a RESTful interface and I would like to marshall and unmarshall JSON ready for Ember Data. The wrinkle is that Ember Data wants the entity name and the two libraries I've tried, spray-json and json4s, don't appear to do this…
Sarge
  • 2,367
  • 2
  • 23
  • 36
0
votes
1 answer

Failing scala test with Future and Json4s

I am a bit puzzled why my test fails when introduce json4s parsing in it. The application itself works fine with it. The application code: import org.json4s.native.JsonMethods class PonyService { protected def client = new PonyClient // Returns…
Petteri H
  • 11,779
  • 12
  • 64
  • 94
0
votes
1 answer

How to "de-sugar" this Scala statement?

LINQ-style queries in Scala with json4s look as follows: val jvalue = parse(text) // (1) val jobject = for(JObject(o) <- jvalue) yield o // (2) I do not understand exactly how (2) works. How would you de-sugar this for-statement ?
Michael
  • 41,026
  • 70
  • 193
  • 341
0
votes
1 answer

Json4s producing weird Json

This is what I have: (("foo" -> ("bar" -> 5) ~ ("bar2" -> 5)) ~ ("something" -> "else")) This is what I get: [ { "foo": { "bar": 5, "bar2": "5" }, "something": "else", } ] But this is what I'd like to get back: { …
goo
  • 2,230
  • 4
  • 32
  • 53
0
votes
1 answer

How can I flatten a JValue before extraction?

For example my json data is like: [{ "name": "Foo", "verified": {"email": true, "mobile": false} }, { "name": "Bar", "verified": {"email": false, "mobile": false} }] With json4s I can get a JArray, before extracting to a list of User (case…
x1a0
  • 9,984
  • 5
  • 22
  • 30
0
votes
1 answer

Flatten extranous fields when extracting using LiftJson or Json4s

I want to extract using LiftJson or Json4s the following Json (not quite but something similar) to the following case classes. { "data": [ { "id": "1234", "message": "Test", "comments": { "data": [ { "id":…
LabOctoCat
  • 611
  • 7
  • 17
-1
votes
1 answer

How to handle double in json in scala

Given { "currency" : { "details" : { "data" : { "code" : "INR", "name" : "Indian Rupee", "symbol" : "₹" } } }, "amt" : 3.247913577689E10 } problem: The above json I am getting as a response in my code…
v1235
  • 11
-1
votes
1 answer

Scala Replacing an object in a list

I have a List of JValues in scala with the following format: [{ id: "foo" values: {...}}, {}] I want to go through the list, and, if the id is equal to a certain value, replace the values. In Java, I have this code newList = List() for (item in…
Daniel
  • 458
  • 7
  • 21
-2
votes
1 answer

How to analyse type mismatch error with Spark Dataset and UDF

I'm working on 2 CSV files to join data and produce JSON Payload using json4s library. I'm facing the issue in mapping spark dataset row with UDF. I tried to create a simple UDF accepting row and returning hardcoded values. The issue remains the…
Tushar Kesarwani
  • 77
  • 1
  • 1
  • 14
-2
votes
2 answers

Scala REST GET request for CURL

How do I convert the following curl request into Scala . I tried the following and it does not work .(getting 401 status code). Any inputs:Any inputs:Any inputs:Any inputs: curl -X GET 'https://api.newrelic.com/v2/applications.json' -H 'X-Api…
Alferd Nobel
  • 3,185
  • 2
  • 30
  • 35
-2
votes
1 answer

Cannot extract data from json with more than 22 fields in scala 2.10

I am trying to extract values from the json dataset where each record has n > 22 key-value pairs. In order to do so, I implemented a case class with n member variables. However, the scala 2.10.x compiler reported "Implementation restriction: case…
yxjiang
  • 240
  • 1
  • 4
  • 8
1 2 3
29
30