Questions tagged [argonaut]

Argonaut is a JSON library for Scala, providing a rich library for parsing, printing and manipulation as well as convenient codecs for translation to and from scala data types.

About

Argonaut is a JSON library for Scala, providing a rich library for parsing, printing and manipulation as well as convenient codecs for translation to and from scala data types.

Argonaut is licenced under BSD3 (see LICENCE).

Links

88 questions
1
vote
0 answers

DecodeJson with All Failed Decoding Attempts?

Given the following from the argonaut docs: import argonaut._ import Argonaut._ case class Person(name: String, age: Int) implicit def PersonDecodeJson: DecodeJson[Person] = jdecode2L(Person.apply)("name", "age") scala> Json.obj("name" ->…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
1
vote
0 answers

Scala shapeless implicit resolution StackOverflowError with ArgonautShapeless

Im using ArgonautShapeless to define some json codecs. When I provide the type for my codec I get StackOverflowError's but If I leave the type off it works. How can I provide the type? My understanding of the problem is that the implicit lookup from…
Stephen
  • 4,228
  • 4
  • 29
  • 40
1
vote
1 answer

Argonaut decoder how to change the type of one value in a case class

Id like to use the casecodecN or shapeless decoder for my case class, but one the fields has a different type when it is json. consider, where b in json is a String like "1.23", but I want it as a Double. case class Foo(a: Double, b: Double) If I…
Stephen
  • 4,228
  • 4
  • 29
  • 40
1
vote
1 answer

Decoding a sealed trait in Argonaut based on JSON structure?

Given the following example: sealed trait Id case class NewId(prefix: String, id: String) extends Id case class RevisedId(prefix: String, id: String, rev: String) extends Id case class User(key: Id, name: String) val json = """ { "key": { …
user107057
  • 121
  • 7
1
vote
1 answer

Cannot compile simple Argonaut expression?

Is this a Scalaz and Argonaut incompatibility issue or is it something else? scala> import argonaut._ import argonaut._ scala> import Argonaut._ import Argonaut._ scala> import scalaz._ import scalaz._ scala> import Scalaz._ import…
user3248346
1
vote
1 answer

JSON of object of type Any and a TypeTag

Given an object of type Any and its TypeTag, how can Argonaut/Shapeless be used to create JSON of it? case class Person(name: String, age: Int) // somewhere in the code where type of 'any' is known, // and we preferrably dont want to include…
eirirlar
  • 814
  • 6
  • 24
1
vote
0 answers

Add additional field to the EncodeJson instance on argonaut-shapeles

Is there a way to specify an additional field which is added to the auto-generated encoder of a case class? The field would be the type field of the sum type the case class is part of, so it generates valid json even in the case the encoder for a…
Reactormonk
  • 21,472
  • 14
  • 74
  • 123
1
vote
1 answer

Complex Encoding of multiple nested classes using scala argonaut

What is wrong with the MainClassEncodeJson method below? Have been following the example for Implicit JSON conversion with Scala http://lollyrock.com/articles/scala-implicit-conversion/ This question is similar to: Encoding nested classes using…
dan-mi-sun
  • 551
  • 2
  • 4
  • 18
1
vote
1 answer

Not enough arguments for method unmarshal: (implicit evidence$1: spray.httpx.unmarshalling.FromResponseUnmarshaller

I am passing from SprayJsonSupport to argonaut based on this example. After some code modification : object ElevationJsonProtocol extends DefaultJsonProtocol { implicit val locationCodec: CodecJson[Elevation] = casecodec2(Elevation,…
SaKou
  • 259
  • 1
  • 13
1
vote
2 answers

Argonaut: Generic method to encode/decode array of objects

I am trying to implement a generic pattern with which to generate marshallers and unmarshallers for an Akka HTTP REST service using Argonaut, handling both entity and collection level requests and responses. I have no issues in implementing the…
cory-p-oncota
  • 33
  • 2
  • 5
1
vote
1 answer

Argonaut - Returning an error in a custom decoder

I'm trying to implement an Argonaut JSON decoder instance that converts JSON strings to instances of my enum QuestionType. The problem is that if the string isn't a valid, the returned DecodeResult should be an error, and I'm not sure how to do…
cib
  • 2,124
  • 2
  • 21
  • 23
1
vote
1 answer

How should I handle mapping over a DecodeResult?

Often, I find myself with JSON that I wish to parse with strings somewhere inside that I want to parse in a non-trivial way (not just to a String). In such a case I need to make a decoder or a codec for it so I might try to do something like the…
TwistedNoodle
  • 281
  • 3
  • 6
1
vote
1 answer

How to modify a numeric JSON field using an Argonaut lens?

Here's a simplified version of an example on Argonaut's lens documentation: import argonaut._, Argonaut._ val obj: Json = Parse.parseOption("""{"a":{"b":"x","c":2}}""").get val lens1 = jObjectPL >=> jsonObjectPL("a") >=> jObjectPL >=>…
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
1
vote
2 answers

FHIR URL - Read Based on Existing Patient

I'm building a FHIR client in .NET using the test server in the following request: http://argonaut.healthintersections.com.au/open/Patient?family=Doe&given=John. I am able to successfully return and parse JSON response for an existing test patient.…
rascend7
  • 15
  • 4
1
vote
1 answer

argonaut - separating failures and successes when extracting List[A]

I have an instance of DecodeJson[A] for a particular type, A, and I have an instance of Json, call it j. I'd like to do something like j.as[List[A]]. However, this JSON is coming to me from a 3rd party, and if some of the items in the array are…
ceedubs
  • 412
  • 3
  • 7