Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Yuval Itzchakov
    @YuvalItzchakov
    I'm unable to find a decoder for Array[T] all of the sudden.
    Lehel Iszlai
    @iszlai

    Hey guys I have a really basic question,
    for a basic webhook thing I'd like to parse json partially and keep a field as string

       val rawJson: String ="""
    {
      "url": "http://bar",
      "method": "GET",
      "body": "{"tucsfoo":""}",
      "cronExpression": "* * * * *"
    }
    """
    case class CronTask(url: String, method: String, body: String, cronExpression: String)
    
    
    
    object CronTask {
      import argonaut._, Argonaut._
      implicit def PersonCodecJson: CodecJson[CronTask] =
        casecodec4(CronTask.apply, CronTask.unapply)("url", "method", "body", "cronExpression")
    }

    I would love to get back the body as a string, how would i do that?

    Gary Pamparà
    @gpampara
    Doesn't that work?
    Lehel Iszlai
    @iszlai
    @gpampara nope :(
    Kevin Meredith
    @kevinmeredith
    Hello! Will CursorHistory#toString, i.e. on a Left of DecodeResult(result: Either[(String, CursorHistory), A) ever include JSON values? Or it will only include the traversed path, i.e. which keys were walked, and which failed
    u can get a List[CursorOp]
    Pyry-Samuli Lahti
    @Pyppe
    Hi guys! If I have a CodecJson[Example] (defined by casecodec20) but would like to change the decoder so that a particular missing field would default to some value, what would be the way to do it?
    The signature of def flatMapCursor(f: HCursor => DecodeResult[HCursor]): DecodeJson[A] looks promising, but I'm not quite sure if and how could it be utilized.
    Pyry-Samuli Lahti
    @Pyppe
    FYI, solved it by using withFocus:
    implicit def decodeJson = DecodeJson[Example] { c =>
      originalCodec.Decoder.decode(
        c.withFocus(js =>
          if (js.hasField("arrayOfStuff")) js
          else js.withObject(_ + ("arrayOfStuff", jEmptyArray))
        )
      )
    }
    Anirudh Vyas
    @AnirudhVyas
    i have a rather simple problem - I have a case class with name, someXField, paths : Seq[String] -- I try to do casecodec3 using argonaut but argonaut cannot recognize Seq[String] - what am I missing? any suggestions
    Pyry-Samuli Lahti
    @Pyppe
    IIRC there's no implicit codec for Seq. Create one youself, or use e.g. List instead
    Anirudh Vyas
    @AnirudhVyas
    I ended up using List.
    thanks for the help
    Francisco Arámburo
    @FrancoAra
    hello
    why is that this works:
    Json
          .obj()
          .as[Option[String]](DecodeJson[Option[String]] { hcursor =>
            (hcursor --\ "lol").as[Option[String]]
          }) shouldBe DecodeResult.ok(None)
    but this fails:
    Json
          .obj()
          .as[Option[OrderStatus]](DecodeJson[Option[OrderStatus]] { hcursor =>
            (hcursor --\ "lol").as[Option[OrderStatus]]
          }) shouldBe DecodeResult.ok(None)
    with: DecodeResult(Left((Attempt to decode value on failed cursor.,CursorHistory(List(El(CursorOpDownField(lol),false)))))) was not equal to DecodeResult(Right(None)) (OrderJsonSpec.scala:30)
    sidnt
    @sidnt
    So, does "io.argonaut" %% "argonaut" % "6.2.2" at the moment, support automatic codec derivation for an ADT?
    toxicafunk
    @toxicafunk
    pretty much that's what it does
    Pyry-Samuli Lahti
    @Pyppe
    Hmm.. The "argonaut-jawn" % "6.2.2" JAR includes only the manifest? Am I missing something? See e.g. http://central.maven.org/maven2/io/argonaut/argonaut-jawn_2.11/6.2.2/argonaut-jawn_2.11-6.2.2.jar
    Pyry-Samuli Lahti
    @Pyppe
    ^ Created Github issue argonaut-io/argonaut#315
    Raymond Barlow
    @raymanoz
    hey peeps
    how does one deal with ADT encode/decode in argonaut?
    toxicafunk
    @toxicafunk
    Alex Cruise
    @acruise
    Hey folks, I know there's an IDSL for path navigation with history, cursors etc., has anyone built a JsonPath/jq style EDSL for it?
    I've built a prototype with https://github.com/json-path/JsonPath but it's not very scala-like
    Kevin Meredith
    @kevinmeredith

    Hi - is argonaut 6.2.2 backwards compatible with 6.2, i.e. it's truly a "patch" version bump?

    https://github.com/argonaut-io/argonaut/releases/tag/v6.2.2

    Nevermind, I see:

    All minor releases (from 6.0 onwards) are binary compatible, i.e. 6.1.x stream are drop in replacements, and the same will be true for 6.2.x, but going from 6.1 to 6.2 may require changes or recompilation.

    on http://argonaut.io/

    Eric K Richardson
    @ekrich
    Hi Guys, trying to convert some test code from lift-json to argonaut so I can take advantage of Scala Native support and 2.13 support. The is the code I'm trying to convert. https://github.com/ekrich/sconfig/blob/master/sconfig/src/test/scala/org/ekrich/config/impl/JsonTest.scala#L60-L92
    The toJson I'm having more luck with. I'm have difficulty with JNumber pattern matching. I have somelike this.
     private[this] def fromJson(json: Json): AbstractConfigValue = {
        import scala.collection.JavaConverters._
    
        json match {
          case JObject(fields) =>
            val m = new HashMap[String, AbstractConfigValue]()
            fields.toMap.foreach({ field =>
              m.put(field._1, fromJson(field._2))
            })
            new SimpleConfigObject(fakeOrigin(), m)
          case JArray(values) =>
            new SimpleConfigList(fakeOrigin(), values.map(fromJson(_)).asJava)
          case JNumber(i) =>
            i match {
              case JsonLong(v) => longValue(v)
              case JNumber(v) => i.
            }
    Also, having some difficulty with matching jNull and or friends.
    Any help appreciated.
    Rohde Fischer
    @rohdef
    is it correctly observed that I cannot parse a String to Json and get some strongly typed error?
    Rohde Fischer
    @rohdef
    I guess the Scaladoc answers that, since I cannot find any error types :)
    D Cameron Mauch
    @DCameronMauch
    I have an ADT called Product (sealed trait with a few case objects). I created encoder and decoder for it. But I need to encode/decode for Option[Product]. How do I do that?
    I would have thought if the base type has an encoder/decoder, it would already know how to handle an Option of that type.
    D Cameron Mauch
    @DCameronMauch
    Ah, my bad. Apparently, my ADT name had a conflict. It thought I was referring to Scala.Product, and not my ADT. Added import, and it works now.
    D Cameron Mauch
    @DCameronMauch
    Does anyone know how to create an encoder for a map? My specific type is Map[String, List[ZonedDateTime]].
    Andriy Plokhotnyuk
    @plokhotnyuk
    @DCameronMauch try jsoniter-scala, it already has much safe and efficient support of any Scala collections and ISO-8601 representation for java.time._ types: implicit val codec: JsonValueCodec[Map[String, List[ZonedDateTime]]] = JsonCodecMaker.make(CodecMakerConfig())
    D Cameron Mauch
    @DCameronMauch
    That doesn’t appear to work with Argonaut. I have no choice but to use Argonaut at this time.
    Andriy Plokhotnyuk
    @plokhotnyuk
    @DCameronMauch you always have choices, just not skip them... btw, I'm not sure that library maintainers care about users: argonaut-io/argonaut#314
    D Cameron Mauch
    @DCameronMauch
    I have to work within the parameters that I am given by the people who employee me. For today, that means I have to use Argonaut. So my only choices involve getting another job or endangering this one.
    Andriy Plokhotnyuk
    @plokhotnyuk
    @DCameronMauch Are their services opened to the wild wide world? Could you please share URL of some their endpoint? I will help you to show them what can happen... ;)
    D Cameron Mauch
    @DCameronMauch
    Just looking for a solution - not to rock the boat
    Rocking the boat and having that be interpreted as a positive and constructive thing is not currently in my skill set
    toxicafunk
    @toxicafunk
    A JSON is a basically a Map already