Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    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
    D Cameron Mauch
    @DCameronMauch
    @toxicafunk thanks!
    Mohamedali10
    @Mohamedali10

    Hi, I have the following string that I pass to a Parse.EncodeEither method like below:

      val test ="""{"key":{"serial":0},"checkIn":true,"repositoryID":"rep_id","state":"disabled"} """
        val re = Parse.decodeEither[A](test).left.map(MalformedContent(_))

    I'am using argonaut 6.2.2, this code result in the below error:

    Left(MalformedContent(String: CursorHistory(List(El(CursorOpDownField(serial),true), El(CursorOpDownField(key),true))),None))
    Mohamedali10
    @Mohamedali10
    could the problem because of the tyoe of the serial number
    toxicafunk
    @toxicafunk
    That A looks suspicious
    Mohamedali10
    @Mohamedali10
    i will try to remove it
    even if I removed the A I have the same issue
    toxicafunk
    @toxicafunk
    Try something like parse(txt) match { case Right(j) => j case Left(failure) => Json.fromString(s"$failure") }
    I think for decodeEither[A] you would need sine case class that describes your Json
    That case class would be your A
    Without a case class for your codec you can only parse to a generic Json
    Mohamedali10
    @Mohamedali10
    parsing works correctly but the problem is with the decoding
    toxicafunk
    @toxicafunk
    So where's your case class and your decoder?
    Mohamedali10
    @Mohamedali10
    Hi is it possible to define Read play-json object from its argonaut decoding?
    Mohamedali10
    @Mohamedali10
    like this:
    object pers {
    
      case class Person(name: String, age: Int)
    
      // Explicit CodecJson instance.
    
      implicit def PersonCodecJson: CodecJson[Person] =
        CodecJson(
          (p: Person) =>
            ("name" := p.name) ->:
              ("age" := p.age) ->:
              jEmptyObject,
          c => for {
            name <- (c --\ "name").as[String]
            age <- (c --\ "age").as[Int]
          } yield Person(name, age))
    
      implicit val p: Reads[Person] = ...
    
    }