Questions tagged [lift-json]

the lift-json parsing and formatting utilities for JSON

A JSON abstract syntax tree (AST) providing the following features:

  • Fast JSON parser
  • LINQ style queries
  • Case classes can be used to extract values from parsed JSON
  • Diff & merge
  • DSL to produce valid JSON
  • XPath like expressions and HOFs to manipulate JSON
  • Pretty and compact printing
  • XML conversions
  • Serialization
  • Low level pull parser API

Github: https://github.com/lift/lift/tree/master/framework/lift-base/lift-json/

130 questions
2
votes
2 answers

Scala Json Lift - MappingException error for one record

I am having issue while parsing json. This issue is coming only if there is one set of record whether all columns are having value or with one or more columns empty value. Other cases it works fine. My case classes for the input is below: case…
Revathi P
  • 77
  • 13
2
votes
1 answer

Parse JSON with Interface/trait and Different implementations

Currently I'm using lift-json to parse json into objects. This is the signature I generally use net.liftweb.json.parse(json).extract[MyClass] This is working fine. However, I'm looking to do a little more. Lets say My class has an object of type…
Carlos Bribiescas
  • 4,197
  • 9
  • 35
  • 66
2
votes
1 answer

How to parse a JSON Scala without case classes

I have a JSON that can change through time and using case Class might be unconvenient because I need to change the structure of it everytime the JSON change. for example, if I have a JSON like this: val json= """{ "accounts": [ { "emailAccount":…
salvob
  • 1,300
  • 3
  • 21
  • 41
2
votes
1 answer

how to set value of attribute in a class and convert it into json using lift json

I have a class named Child which I want to convert into JSON using Lift Json. Everything is working fine, but the problem is I am setting the value of an attribute through a Scala setter but this new value is not stored in Json. Here is the code…
swaheed
  • 3,671
  • 10
  • 42
  • 103
2
votes
1 answer

lift-json cannot deserialize optional fields

Got exception when trying to serialize/deserialize case class with optional field using lift-json. scala> import net.liftweb.json._ import net.liftweb.json._ scala> import net.liftweb.json.Serialization.{read, write} import…
Jerry Xu
  • 41
  • 3
2
votes
1 answer

How to serialize JNothing as null

With lift-json backed json4s, if I do the following: val foobar = ("foo" -> JNothing) ~ ("bar" -> 42) println(write(foobar)) The output is: {, "bar":42} which is not valid JSON. I would like to obtain: {"foo":null, "bar":42} Is there any way to…
Eduardo
  • 8,362
  • 6
  • 38
  • 72
2
votes
3 answers

In Scala what is the easiest way to parse json and map to objects?

I'm looking for a super simple way to take a big JSON fragment, that is a long list with a bunch of big objects in it, and parse it, then pick out the same few values from each object and then map into a case class. I have tried pretty hard to get…
jpswain
  • 14,642
  • 8
  • 58
  • 63
2
votes
1 answer

Lift JSON LINQ Like Dynamic Extraction Pattern

I am attempting to perform an XPath based extraction using Lift JSON except that the xpath pattern of extraction is determined during runtime To illustrate, I'd like to convert string "a.b.c.d" to Lift JSON extraction using (json \ "a" \ "b" \…
conikeec
  • 209
  • 2
  • 14
2
votes
3 answers

How to Conditionally Produce JSON Using JSON4S

I am using JSON4S to produce some JSON. If a condition is met, I would like to produce the following: {"fld1":"always", "fld2":"sometimes"} If the condition is not met, I would like to produce: {"fld1":"always"} What I have tried so far is: val…
Eduardo
  • 8,362
  • 6
  • 38
  • 72
2
votes
2 answers

Get json data in d3 from lift snippet

I am currently implementing a graph using d3 and a json object for data. A working example of such a graph can be found here: http://bl.ocks.org/950642. If you know d3 you can certainly directly jump to the My Problem part. Quick overview of…
Christopher Chiche
  • 15,075
  • 9
  • 59
  • 98
2
votes
1 answer

Ignoring fields when deserialising with lift-json in Scala

How does I deserialise data like this into a case class like this: case class SoundCloudUser ( id: Int, permalink: String, username: String, country: String, full_name: String, city: String, description: String) (that is, where the…
chrism
  • 561
  • 4
  • 14
1
vote
1 answer

Non-recursive extraction in Lift JSON for-comprehension

I'm using Lift JSON's for-comprehensions to parse some JSON. The JSON is recursive, so e.g. the field id exists at each level. Here is an example: val json = """ { "id": 1 "children": [ { "id": 2 }, { "id": 3 } …
Ben Challenor
  • 3,365
  • 1
  • 35
  • 35
1
vote
1 answer

Instantiate a type based on json and metadata using lift-json

I would like to deserialise Scala case classes that have been serialised using lift-json. The problem I am having is, I don't know how to invoke the generic method extractOpt[A] method below: someString:String =…
Noel Kennedy
  • 12,128
  • 3
  • 40
  • 57
1
vote
2 answers

Rendering JSON from parsed JSON using lift-json in Scala

This is probably an easy one and my difficulty is likely caused by my newness to Scala (which already is fast becoming my favourite language). Basically I have some JSON that looks like this: { "to" : "Peter", "from" : "Dave", "bundle" : [ …
PeterM
  • 2,534
  • 6
  • 31
  • 38
1
vote
2 answers

how to serve a Lift/Scala Json webservice from mapper persistant class

Ok, firstly I am new to posting questions here, so go easy on me. I feel like I have scowered the interwebs to figure this out, and I sure must be slow because I just cant get it right - I know this should be simple. I have a class: class Produce…
mikemwalsh
  • 35
  • 3
1 2
3
8 9