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

86 questions
69
votes
1 answer

What are the problems with an ADT encoding that associates types with data constructors? (Such as Scala.)

In Scala, algebraic data types are encoded as sealed one-level type hierarchies. Example: -- Haskell data Positioning a = Append | AppendIf (a -> Bool) | Explicit ([a] -> [a]) // Scala sealed trait…
missingfaktor
  • 86,952
  • 56
  • 271
  • 360
12
votes
1 answer

Cannot find an implicit ExecutionContext. You might pass spray scala

I have this two erros: Error:(39, 20) Cannot find an implicit ExecutionContext. You might pass an (implicit ec: ExecutionContext) parameter to your method or import scala.concurrent.ExecutionContext.Implicits.global. val pipeline = sendReceive …
kam kimo
  • 173
  • 1
  • 2
  • 7
11
votes
2 answers

Update case class from incomplete JSON with Argonaut or Circe

I need to create an updated instance from a case class instance (with any needed DecodeJsons implicitly derived), given an incomplete json (some fields missing). How can this be accomplished with Argonaut (preferably) or Circe (if I have…
eirirlar
  • 795
  • 5
  • 23
9
votes
2 answers

Encoding nested classes using scala argonaut

I'm trying to encode/decode following case class case class Person(name: String, age: Int, childs: List[Person]) using the following code: object Person { implicit def PersonCodecJson = casecodec3(Person.apply, Person.unapply)("name",…
Daniel
  • 91
  • 4
7
votes
3 answers

Parse JSON array using Scala Argonaut

I'm using Scala & Argonaut, trying to parse the following JSON: [ { "name": "apple", "type": "fruit", "size": 3 }, { "name": "jam", "type": "condiment", "size": 5 }, { …
Gilbert
  • 2,714
  • 1
  • 21
  • 30
6
votes
0 answers

Argonaut CodecJson and decoding subtypes

In the Argonaut DecodeJson trait there is a method ||| for chaining together decoders, so that the first succeeding decoder is chosen. There is also a similar method in DecodeResult which has the same effect. It looks at first glance as though one…
Robin Green
  • 29,408
  • 13
  • 94
  • 178
5
votes
0 answers

How to write a Scala Argonaut codec for all Java enums

I have a Scala project that uses a bunch of Java code, for example this Java source: public enum Category { FOO, BAR }; I then have a bunch of Scala case classes that I serialise to and from JSON using Argonaut like this: case class Thing (a:…
sungiant
  • 2,956
  • 5
  • 29
  • 46
4
votes
1 answer

Collecting Elements in a JSON Array

I having big toruble with Argonaut. I am needing to collect all elements in JSON array. For example, I having this data in JSON. val data = """{"id": 1, "items": [{"name": "foo","price": 10},{"name": "bar","price": 20}]}""" Then I am needing to…
Mojo
  • 956
  • 4
  • 13
4
votes
1 answer

`circe` Type-level Json => A Function?

Using circe or argonaut, how can I write a Json => A (note - Json may not be the name of the type) where A is given by the SSN class: // A USA Social Security Number has exactly 8 digits. case class SSN(value: Sized[List[Nat],…
Kevin Meredith
  • 38,251
  • 58
  • 190
  • 340
4
votes
2 answers

Mapping over a JSON array with Argonaut

I'm having a hard time slogging through the Argonaut documentation, so I figured I'd just ask for a simple example. val input = """{"a":[{"b":4},{"b":5}]}""" val output = ??? // desired value: List(4, 5) I can get a cursor down to the…
Chris Martin
  • 28,558
  • 6
  • 66
  • 126
4
votes
1 answer

creating Writeable[Argonaut.Json] for play framework http response

I am trying to change the implementation of this function from using plays json library like so def apply[T](action: => ApiResponse[T])(implicit tjs: Writes[T], ec: ExecutionContext): Future[Result] = { action.fold( err => …
Mark
  • 2,889
  • 4
  • 34
  • 74
4
votes
1 answer

How to ignore an item when generating the json string if the value is None?

I'm trying to use Argonaut to generate JSON string from a Scala instance. import argonaut._, Argonaut._ case class Person(name: Option[String], age: Int, things: List[String]) implicit def PersonCodecJson = casecodec3(Person.apply,…
Freewind
  • 177,284
  • 143
  • 381
  • 649
4
votes
2 answers

Converting JSON field names in argonaut

I'm writing a library to convert JSON responses from an API for backwards compatibility reasons. And what I need to do is take in arbitrary JSON, and change certain field names. I'm using scala and argonaut, but I don't see any way in the docs or…
Falmarri
  • 44,586
  • 38
  • 140
  • 186
4
votes
2 answers

Using Argonaut to create generic JSON converter

I'm new to Scala, and here I'm trying to create a generic json converter based on Argonaut. I've tried to search on google and stackoverflow, but so far I have no clue. Here is the snippet of my code. import…
Wins
  • 3,083
  • 3
  • 29
  • 61
3
votes
1 answer

Argonaut: decoding a polymorphic array

The JSON object for which I'm trying to write a DecodeJson[T] contains an array of different "types" (meaning the JSON structure of its elements is varying). The only common feature is the type field which can be used to distinguish between the…
ceran
  • 1,297
  • 1
  • 15
  • 41
1
2 3 4 5 6