Search code examples
javajsongson

How to read json variable "@odata.context" in Java using Gson?


In Json, i have following

{  "@odata.context":"https://te.avolutionsoftware.com/api/$metadata#Components/$entity"

When i translate Json to java i get following:

private String @odata.context;

and compiler is not allowing that.

Any idea how to read this variable particularly in Gson library or in general what to search?


Solution

  • @SerializedName might help you . like this:

    public final class Context {
            @SerializedName("@odata.context")
            public String context;
        
        }