by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    lemonxah
    @lemonxah
    it does this for all list types
    and i do have
    import com.konga.order.models.OrderJsonSupport._
    import DefaultJsonProtocol._
    Arnout Engelen
    @raboof
    @lemonxah have you verified it works for com.konga.order.models.Order when it's not in a List?
    lemonxah
    @lemonxah
    nvm found the issue .. the OrderJsonSupport extended DefaultJsonProtocol as well removed that and it works
    Arnout Engelen
    @raboof
    ah yes if you have multiple matching implicits the compiler sometimes makes it look like none matched, very confusing indeed
    lemonxah
    @lemonxah
    normally i would have ambigious implicit
    but now .. nothing matched .. that was very confusing
    Abhiraj Padhye
    @A4Abhiraj
    Hey everyone! This issue is still open. Can anyone help ?
    spray/spray-json#159
    Andrey Ivanov
    @a-nigredo

    Hi all, I am busy with migration from spray to akka-http and don't understand what happens with such a code:

    def route = path(Segment) {
     actorReffactory.actorOf("")
    }

    What will be in a response then?

    How spray process actorRef as a response?
    Konrad `ktoso` Malawski
    @ktoso
    this won’t compile
    please ask on gitter.im/akka/akka btw :)
    it won’t compile, exactly because the question you ask can’t be answered statically — akka http enforces these things
    Andrey Ivanov
    @a-nigredo
    @ktoso I know that it is not compiled in akka-http but in spray. My question is what convertion spray uses to handle such case?
    Jameel Al-Aziz
    @jalaziz
    Curious if this is a known thing before I open up a ticket. RouteTest in the testkit appears to eagerly create and start the actor system. While this normally wouldn't be an issue, we use ScalaTest's tagging to include/exclude tests. The eager loading slows things down considerably as the actor system will be initialized even though no tests are actually run.
    Konrad `ktoso` Malawski
    @ktoso
    Spray has been end of life since a few years, please migrate do akka-http (migration is usually rather simple), and ask there then
    Jameel Al-Aziz
    @jalaziz
    ahh, good point, forgot about that, we actually do use akka-http for newer things
    thanks!
    although, looks like it's still eager in akka-http, but will upgrade first
    Konrad `ktoso` Malawski
    @ktoso
    yeap, upgrade and ask on https://discuss.akka.io I propose :) happy hakking
    ShankarShastri
    @shankarshastri
    Is there a way to parse a JSON like this in spray?
    {
    "k1": [
    "k2": { "k3" : 1 },
    "k4": {"k41" : 2}
    ]
    }
    Kirill Yankov
    @manonthegithub

    @shankarshastri you can use spray-json.

    import spray.json._
    val jsonString: String = ???
    
    val json: JsObject = jsonString.parseJson.asJsObject

    or you can declare a class describing this json and declare format for it and then convert to it directly:

    
    class JsonRepr(???)
    
    implicit object ReprFormat extends RootJsonFormat[JsonRepr]{
       ???
    }
    
    import spray.json._
    val jsonString: String = ???
    jsonString.parseJson.convertTo[ReprFormat]
    ShankarShastri
    @shankarshastri
    But I don't know the key names @manonthegithub
    to specify them in case class
    Kirill Yankov
    @manonthegithub
    then probably the first sample val json: JsObject = jsonString.parseJson.asJsObject is your option
    you can then get Map[String, JsValue] of the fields of the JsObject
    jsonString.parseJson.asJsObject.fields will return Map[String, JsValue]
    ShankarShastri
    @shankarshastri
    I wanted to understand spray json library.
    Any hints to tell where to start from?
    I meant code.
    Vladislav Rybin
    @VladislavRybin
    hey guys, does anyone else have false error highlights in spray routes when using IntelliJ IDEA?
    All my code is covered in red highlighting :^)
    Is there a way to fix this?
    Arnout Engelen
    @raboof
    @VladislavRybin in akka-http you can use concat instead of ~ which might be less prone to confusing IntelliJ - not sure if that was in Spray already though (https://doc.akka.io/docs/akka-http/current/routing-dsl/directives/index.html)
    Konrad `ktoso` Malawski
    @ktoso
    it wasn't
    please upgrade to akka-http; spray has been end-of-life for years
    the upgrade is rather straight forward
    ShankarShastri
    @shankarshastri
    Guys wanted help regarding this one:
    spray/spray-json#257
    How to provide default values for optional parameters in request payload while marshalling ?
    ShankarShastri
    @shankarshastri
    @ktoso @jrudolph your help required on the above issue.
    Arnout Engelen
    @raboof
    @shankarshastri this is currently not supported in spray-json, but if it's just a couple of classes you could write your own custom readers? the generated writer might already do what you want?
    ShankarShastri
    @shankarshastri
    @raboof , can you give me a example, or if present in readme.md can you suggest me?
    Arnout Engelen
    @raboof
    @shankarshastri if you search for def read in the README those are examples of different ways to 'manually' write readers
    vito-c
    @vito-c
    this room still active? :D how do I marshal a case class to json when using akka-http websocket? I am sending json with the akka-http websocket client.
    Arnout Engelen
    @raboof
    @vito-c most people have moved to akka-http and discuss it in akka/akka or https://discuss.akka.io I think
    @vito-c for marshalling case classes in akka-http I think both spray-json and play-json are still popular
    I'm not sure about websockets specifically but still https://doc.akka.io/docs/akka-http/current/common/json-support.html#json-support might help?
    vito-c
    @vito-c
    @raboof how would one marshal to a just a Message? I can do it automatically to a MessageEntity
    could not find implicit value for parameter m: akka.http.scaladsl.marshalling.Marshal
    ler[eneovim.EnMessage,akka.http.scaladsl.model.ws.Message]
    [error]   val outgoing = Source.fromFuture(Marshal(myMsg).to[Message])
    [error]                                                     ^
    Arnout Engelen
    @raboof
    @vito-c do you mean HttpEntity? It works for those because of the implicit conversion at https://github.com/akka/akka-http/blob/master/akka-http-marshallers-scala/akka-http-spray-json/src/main/scala/akka/http/scaladsl/marshallers/sprayjson/SprayJsonSupport.scala#L65, you might want to introduce a similar one for Message
    (you're writing a Scala plugin for neovim? that sounds pretty cool)
    Arnout Engelen
    @raboof
    (ah I see you found akka/akka :smile: )
    vito-c
    @vito-c
    hi @raboof yah I'm working on a scala based ensime plugin (mostly for fun) :) I'm looking at that SprayJsonSupport for Message now ... do you have an example of a Marshaller for another internal?
    Arnout Engelen
    @raboof
    @vito-c not really... not sure I understand exactly what you need but something like implicit def sprayJsonToWsMessageMarshaller[T](implicit writer: RootJsonWriter[T], printer: JsonPrinter = CompactPrinter): Marshaller[T, Message] = Marshaller.strict(t => Marshalling.Opaque(() => TextMessage(writer.write(t)))) might work?
    JoeCordingley
    @JoeCordingley
    Hi. The spray testkit doesn't seem to work with contentType. I have an example here: https://github.com/JoeCordingley/spray-marshallersExample where if you hit localhost:8080 with either application/json or application/myJson in the running service it returns the correct contentType but testing the route using spray testkit it always returns application/json