Skip to content

Conversation

deeptimarrivada1
Copy link
Contributor

resolves #1425

@google-cla
Copy link

google-cla bot commented Sep 6, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@deeptimarrivada1
Copy link
Contributor Author

deeptimarrivada1 commented Sep 6, 2022

Sample test method:

@Test
    public void test() {
        String inputString
                = "{\"clazz\":com.foo.MyObject,\"value\":20}";
        IdDeserializer deserializer = new IdDeserializer();
        Gson gson = new GsonBuilder()
                .registerTypeAdapter(Id.class, deserializer)
                .create();
        Id outList = gson.fromJson(inputString, new TypeToken<Id>(){}.getType());
        System.out.println(outList.getValue());
    }

Copy link
Contributor

@Marcono1234 Marcono1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to sign the CLA? I think it will be necessary for this PR to be merged.

@deeptimarrivada1
Copy link
Contributor Author

Are you able to sign the CLA? I think it will be necessary for this PR to be merged.

yes

@deeptimarrivada1
Copy link
Contributor Author

deeptimarrivada1 commented Sep 9, 2022

Sample test:

@Test
   public void test() {
       Id id = new Id(Foo.class, 20);
       Gson gson = new GsonBuilder().registerTypeAdapter(Id.class, new IdSerializer()).create();
       Gson gson2 = new GsonBuilder()
               .registerTypeAdapter(Id.class, new IdDeserializer())
               .create();
       Id outList = gson2.fromJson(gson.toJson(id), new TypeToken<Id>(){}.getType());
       System.out.println(outList.getValue());
   }

Copy link
Contributor

@Marcono1234 Marcono1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your work on this!

@eamonnmcmanus, could you please have a look?

@eamonnmcmanus
Copy link
Member

Thanks for doing this!

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

Successfully merging this pull request may close these issues.

JsonDeserializer API doc example may be incomplete-cannot resolve symbol 'id'

3 participants