Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for various JSON libraries #846

Open
magnolia-k opened this issue Jul 22, 2018 · 6 comments
Open

Support for various JSON libraries #846

magnolia-k opened this issue Jul 22, 2018 · 6 comments

Comments

@magnolia-k
Copy link
Contributor

I wrote a prototype of support for Spray-Json and Argonaut

Spray-JSON

magnolia-k@46d8a5c

Argonaut

magnolia-k@caad122

Things to decide to support various JSON libraries

  • JSONP support
  • Generate response directly from case class
  • Which JSON library to support
@takezoe
Copy link
Member

takezoe commented Jul 25, 2018

@magnolia-k Great! I will check your code as soon as possible.

@takezoe
Copy link
Member

takezoe commented Jul 27, 2018

Generate response directly from case class

I think it's impossible to make with the current Scalatra API because it allows any types as the result of the action. Dramatic changes in core API is necessary.

My idea is defining a type class like Renderable[T] and each action take an instance corresponding to a result type of itself. Of course, it affects not only JSON actions, but all actions.

Which JSON library to support

spray-json and argonaut is good start of the multiple JSON library support in Scalatra!

@magnolia-k
Copy link
Contributor Author

thank you for your comment
As you pointed out, I think that it is difficult to support other JSON libraries in the same way, as the current JSON support strongly depends on Json4s specific functions.

There seems to be a need to think towards the function of Scalatra 3.0 (?).

First of all, prepare for Scalatra 2.7 with case class support removed.

@takezoe
Copy link
Member

takezoe commented Jul 28, 2018

There seems to be a need to think towards the function of Scalatra 3.0 (?).

Make sense.

First of all, prepare for Scalatra 2.7 with case class support removed.

What does it mean?

@magnolia-k
Copy link
Contributor Author

What does it mean?

If we put Spray-Json and Argonaut's support in 2.7, we mean we have to decide whether or not to add without support for case class

It does not mean to remove case class support from json4s.
(I was sorry that the explanation was insufficient)

@takezoe
Copy link
Member

takezoe commented Jul 29, 2018

I totally understood.

While that's nice as a first step of multiple JSON library support, I would like to consider introducing the type class to render response. But I'm not sure whther it's possible to introduce it in Scalatra 2.7 at the moment.

We will able to consider case class support in JSON support after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants