From the Kotlin documentation :
// public final class Gson { // ... // public <T> T fromJson(JsonElement json, // Class<T> classOfT) // throws JsonSyntaxException { // ...
In the code snippet above, I understand everything except Class<T> . I assume this is the C # equivalent of the following:
public sealed class Gson { public T FromJson<T>(JsonElement json, System.Type Type) { } }
And the client code will say something like:
var gson = new Gson(); var customer = gson.FromJson<Customer>(json, typeof(Customer));
But I canβt be sure, because all this System.Type parameter seems redundant in the face of the type type parameter T in the method definition.
Also, in the same place on this page, what is class.java in the following snippet?
inline fun <reified T: Any> Gson.fromJson(json): T = this.fromJson(json, T::class.java)
I assume that the Class class in Java is similar to System.Type , so if you want to say typeof(Customer) , would you say Customer.class ? It is right?
What is class.java ?
source share