Document using Gson mapper in Kotlin
See original GitHub issue👋 hi! I’ve been taking a look at Javalin today, and have been considering converting a tiny ktor project to it (the tl;dr there being that most of the addons to ktor that make it a more complete framework are still labeled “experimental,” and I don’t really need the async capabilities it has).
One stumbling block along the way was that I wanted to use Gson (since my existing resources were already relying on it), but trying to set:
val gson = GsonBuilder().create()
JavalinJson.fromJsonMapper = gson::fromJson
lead to a rather verbose type error.
After googling a bit, I eventually found the example you added to this repo, which appears to work. It would be nice if a link to this could be added to the documentation under “configuring the JSON mapper”, since it took me a while to find that.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Kotlin - Convert object to/from JSON string using Gson
Gson is a Java/Kotlin library for converting Java/Kotlin Objects into JSON representation, also a JSON string to an equivalent Java/Kotlin ...
Read more >Converting Kotlin Data Class from JSON using GSON
1. Overview. In this short tutorial, we'll discuss how to convert a data class in Kotlin to JSON string and vice versa using...
Read more >Parsing between JSON and Kotlin Object with Google Gson ...
In this tutorial I will discuss about how to parse a class object into json string and convert it back from json string...
Read more >Kotlin Data Class from Json using GSON - java - Stack Overflow
@AntonGolovin I am not able to pass my data class in from Json method.Do I need to declare my data class inside java...
Read more >Convert Object to/from JSON with Gson - Kotlination
This tutorial shows you how to use Gson to convert Kotlin object to/from JSON.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Whoops, this slipped my mind. Should be able to do this in the next day or two!
Should I take over this @thomasboyt ?