public static Customer deserializeWith(final byte[] inputBytes) throws IOException { final JsonReader reader = new JsonReader(inputBytes); if (reader.getNextToken() != '{') throw new IOException("Expecting '{'"); return deserialize(reader, null); }
public static Customer deserialize(final JsonReader reader, final ServiceLocator locator) throws IOException { String _uri = ""; long _id = 0L; String _name = ""; Profile _profile = new Profile(); ArrayList<Account> _accounts = null; if (reader.read() == '}') return new Customer(_uri, _id, _name, _profile, _accounts, locator); int nameHash = reader.fillName(); int nextToken = reader.moveToNextToken(); if (nextToken == 'n') { if (reader.read() != 'u' || reader.read() != 'l' || reader.read() != 'l') throw new IOException("null value expected"); } else { switch (nameHash) { case 1: _uri = reader.readString(); nextToken = reader.getNextToken(); break; case 25458: _id = Long.parseLong(reader.readRawNumber()); nextToken = reader.getNextToken(); break; case 24614690: _name = reader.readString(); nextToken = reader.getNextToken(); break; case 1120506290: if (reader.read() != '{') throw new IOException("Expecting '{'. Found: " + (char) reader.read()); nextToken = reader.getNextToken(); _profile = ProfileManualOptJsonSerialization.deserialize(reader); nextToken = reader.getNextToken(); break; case -758926083: if (reader.read() != '[') throw new IOException("Expecting '['. Found: " + (char) reader.read()); nextToken = reader.getNextToken(); if (reader.read() != '{') throw new IOException("Expecting '{'. Found: " + (char) reader.read()); nextToken = reader.getNextToken(); _accounts = new ArrayList<Account>(); _accounts.add(AccountManualOptJsonSerialization.deserialize(reader)); while ((nextToken = reader.getNextToken()) == ',') { nextToken = reader.getNextToken(); if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = reader.getNextToken(); _accounts.add(AccountManualOptJsonSerialization.deserialize(reader)); } nextToken = reader.getNextValidToken(); break; default: nextToken = reader.skip(); break; } } while (nextToken == ',') { nextToken = reader.moveToNextToken(); nameHash = reader.fillName(); nextToken = reader.moveToNextToken(); if (nextToken == 'n') { if (reader.read() == 'u' && reader.read() == 'l' && reader.read() == 'l') { nextToken = reader.getNextToken(); continue; } throw new IOException("null value expected"); } else { switch (nameHash) { case 1: _uri = reader.readString(); nextToken = reader.getNextToken(); break; case 25458: _id = Long.parseLong(reader.readRawNumber()); nextToken = reader.getNextToken(); break; case 24614690: _name = reader.readString(); nextToken = reader.getNextToken(); break; case 1120506290: if (reader.read() != '{') throw new IOException("Expecting '{'. Found: " + (char) nextToken); nextToken = reader.getNextToken(); _profile = ProfileManualOptJsonSerialization.deserialize(reader); nextToken = reader.getNextToken(); break; case -758926083: if (reader.read() != '[') throw new IOException("Expecting '['. Found: " + (char) reader.read()); nextToken = reader.getNextToken(); if (reader.read() != '{') throw new IOException("Expecting '{'. Found: " + (char) reader.read()); nextToken = reader.getNextToken(); _accounts = new ArrayList<Account>(); _accounts.add(AccountManualOptJsonSerialization.deserialize(reader)); while ((nextToken = reader.getNextValidToken()) == ',') { reader.invalidate(); if (reader.read() != '{') throw new IOException("Expecting '{'"); nextToken = reader.getNextValidToken(); _accounts.add(AccountManualOptJsonSerialization.deserialize(reader)); } nextToken = reader.getNextValidToken(); break; default: nextToken = reader.skip(); break; } } } if (nextToken != '}') { if (nextToken == -1) throw new IOException("Unexpected end of json in object Transaction"); else throw new IOException( "Expecting '}' at position " + reader.positionInStream() + ". Found " + (char) nextToken); } return new Customer(_uri, _id, _name, _profile, _accounts, locator); }