spray-json: unmarshalling data with ampersand prefixed keyname

16 views
Skip to first unread message

imda...@gmail.com

unread,
May 13, 2015, 12:22:27 PM5/13/15
to spray...@googlegroups.com

Hello,

I'm taking a JSON feed which I'm then unmarshalling. I'm using spray-json and a custom case class to do this.

The problem I'm having is being able to to extract one entries keyname which has been prefixed with an ampersand, where as the other keys are easily coped with, e.g.,

// data
{..., "@id" : "string", ...}

// class
case class Response(..., `@id`: String, ...)

The error I get when I run my tests from fixtures is this. Renaming the keyname, in the data and the class to 'id', doesn't create the error and I've not found much on the web agianst this specific problem.

Caused by java.lang.RuntimeException: Cannot automatically determine case class field names and order for 'spray.example.domain.Response', please use the 'jsonFormat' overload with explicit field name specification

So far I've only found examples for adding custom unmarshallers against values instead of keynames. Is there way to seralise the data using a custom unmarsaller against keyname? If so, how might this be done?

Thanks all

Johannes Rudolph

unread,
May 13, 2015, 12:25:13 PM5/13/15
to spray...@googlegroups.com
Hi,

are you using the latest version of spray-json (1.3.2) released last
week? It contained a fix for a similar (the same?) problem:

https://github.com/spray/spray-json/issues/142

Johannes
> --
> You received this message because you are subscribed to the Google Groups
> "spray.io User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to spray-user+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/spray-user.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/spray-user/cb479949-1cd6-40e2-b9fc-a6d53125d7d6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net

imda...@gmail.com

unread,
May 14, 2015, 2:31:01 AM5/14/15
to spray...@googlegroups.com
Hi Johannes,

> https://github.com/spray/spray-json/issues/142

Yep this did it.. was the same issue and welcome the fast fix.

Thanks
Reply all
Reply to author
Forward
0 new messages