For many years now I've been delivering JSON respo...
# questions
j
For many years now I've been delivering JSON responses from my Grails controllers, either by use of marshallers or often simply by using 'to JSON' with a map derived from the object using e.g. 'subMap'. I've never felt the requirement to use JSON views but there is clearly a push to get people to use them (object marshallers, for example, are not in the current documentation). I felt I was swimming against the current somewhat so today I decided to give have a look at JSON views. I have to say I had a LOT of difficulty getting it to work, because I kept getting errors like this: 2024-12-12 114331.725 ERROR --- [nio-8080-exec-3] o.s.b.w.servlet.support.ErrorPageFilter : Forwarding to error page from request [/guardian/tripHistory] due to exception [Could not resolve view with name '/guardian/tripHistory' in servlet with name 'grailsDispatcherServlet'] javax.servlet.ServletException: Could not resolve view with name '/guardian/tripHistory' in servlet with name 'grailsDispatcherServlet' This is even though there absolutely was a 'tripHistory.gson' file in the correct location. I thought I had the JSON Views plugin properly installed, but clearly not. In the end I created a demo app on Application Forge with the plug-in installed, and copied some settings from the build.gradle there to the build.gradle in my app and eventually got things working. But I'm looking at this and wondering what it actually buys me? What does this enable me to do which I can't do just as easily in code? I like to go with the flow where possible, but I'm just not quite getting this.
r
I’m an old 2.5.6? User but I never used the groovy json stuff it’s too fat and slow. Maybe later versions changed. We used Jackson as it’s super fast and speed was important.