Last active
March 2, 2016 18:54
-
-
Save karthikrg/a1452ee7ef96c7c208df to your computer and use it in GitHub Desktop.
Pegasus jackson stream parser bindings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public MemberProfile build(@android.support.annotation.NonNull JsonParser jsonParser) throws java.io.IOException { | |
if (jsonParser.getCurrentToken() == null) { | |
jsonParser.nextToken(); | |
} | |
if (jsonParser.getCurrentToken()!= JsonToken.START_OBJECT) { | |
jsonParser.skipChildren(); | |
throw new java.io.IOException("Malformed JSON. Failed to find '{' when building com.linkedin.android.pegasus.MemberProfile"); | |
} | |
String firstName = null; | |
String lastName = null; | |
String companyName = null; | |
int age; | |
while (jsonParser.nextToken()!= JsonToken.END_OBJECT) { | |
String __fieldName = jsonParser.getCurrentName(); | |
jsonParser.nextToken(); | |
if ("firstName".equals(__fieldName)) { | |
firstName = ((String) jsonParser.getValueAsString()); | |
jsonParser.skipChildren(); | |
continue; | |
} | |
if ("lastName".equals(__fieldName)) { | |
lastName = ((String) jsonParser.getValueAsString()); | |
jsonParser.skipChildren(); | |
continue; | |
} | |
if ("companyName".equals(__fieldName)) { | |
companyName = ((String) jsonParser.getValueAsString()); | |
jsonParser.skipChildren(); | |
continue; | |
} | |
if ("age".equals(__fieldName)) { | |
age = (int) jsonParser.getValueAsNumber(); | |
jsonParser.skipChildren(); | |
continue; | |
} | |
jsonParser.skipChildren(); | |
continue; | |
} | |
if (firstName == null) { | |
throw new java.io.IOException("Failed to find required field: firstName var: firstName when building com.linkedin.android.pegasus.MemberProfile"); | |
} | |
return new MemberProfile(firstName, lastName, companyName, age); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment