Java Code Examples for android.util.JsonToken#END_OBJECT
The following examples show how to use
android.util.JsonToken#END_OBJECT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GalleryData.java From NClientV2 with Apache License 2.0 | 6 votes |
private void parseJSON(JsonReader jr) throws IOException { jr.beginObject(); while(jr.peek()!= JsonToken.END_OBJECT){ switch(jr.nextName()){ case "upload_date":uploadDate=new Date(jr.nextLong()*1000);break; case "num_favorites":favoriteCount=jr.nextInt();break; case "media_id":mediaId=jr.nextInt();break; case "title":readTitles(jr);break; case "images":readImages(jr); break; case "tags":readTags(jr);break; case "id":id=jr.nextInt();break; case "num_pages":pageCount=jr.nextInt();break; case "error":jr.skipValue(); valid=false;break; default:jr.skipValue();break; } } jr.endObject(); }
Example 2
Source File: GalleryData.java From NClientV2 with Apache License 2.0 | 6 votes |
private void readImages(JsonReader jr) throws IOException { int actualPage=0; jr.beginObject(); while (jr.peek()!=JsonToken.END_OBJECT){ switch (jr.nextName()){ case "cover": cover= new Page(ImageType.COVER,jr); break; case "pages": jr.beginArray(); while(jr.hasNext()) pages.add(new Page(ImageType.PAGE,jr,actualPage++)); jr.endArray(); break; case "thumbnail": thumbnail= new Page(ImageType.THUMBNAIL,jr); break; default: jr.skipValue(); break; } } jr.endObject(); pages.trimToSize(); }
Example 3
Source File: User.java From NClientV2 with Apache License 2.0 | 5 votes |
public User(JsonReader reader) throws IOException { reader.beginObject(); while(reader.peek()!= JsonToken.END_OBJECT){ switch (reader.nextName()){ case "id":id=reader.nextInt();break; case "post_date":username=reader.nextString();break; case "avatar_url":avatarUrl=reader.nextString();break; default:reader.skipValue();break; } } reader.endObject(); }
Example 4
Source File: Comment.java From NClientV2 with Apache License 2.0 | 5 votes |
public Comment(JsonReader reader) throws IOException { reader.beginObject(); while(reader.peek()!= JsonToken.END_OBJECT){ switch (reader.nextName()){ case "id":id=reader.nextInt();break; case "post_date":postDate=new Date(reader.nextLong()*1000);break; case "body":body=reader.nextString();break; case "poster":poster=new User(reader);break; default:reader.skipValue();break; } } reader.endObject(); }
Example 5
Source File: Page.java From NClientV2 with Apache License 2.0 | 5 votes |
public Page(ImageType type, JsonReader reader,int page)throws IOException{ this.imageType=type; this.page=page; reader.beginObject(); while (reader.peek()!= JsonToken.END_OBJECT){ switch (reader.nextName()){ case "t":imageExt=stringToExt(reader.nextString()); break; case "w":size.setWidth(reader.nextInt()); break; case "h":size.setHeight(reader.nextInt()); break; default:reader.skipValue();break; } } reader.endObject(); }
Example 6
Source File: Tag.java From NClientV2 with Apache License 2.0 | 5 votes |
public Tag(JsonReader jr) throws IOException { jr.beginObject(); while(jr.peek()!= JsonToken.END_OBJECT){ switch (jr.nextName()){ case "count":count=jr.nextInt();break; case "type":type=TagType.typeByName(jr.nextString());break; case "id":id=jr.nextInt();break; case "name":name=jr.nextString();break; case "url": LogUtility.d("Tag URL: "+jr.nextString());break; default:jr.skipValue();break; } } jr.endObject(); }
Example 7
Source File: GalleryData.java From NClientV2 with Apache License 2.0 | 5 votes |
private void readTitles(JsonReader jr) throws IOException { jr.beginObject(); while(jr.peek()!=JsonToken.END_OBJECT){ switch (jr.nextName()){ case "japanese":setTitle(TitleType.JAPANESE,jr.peek()!=JsonToken.NULL?jr.nextString():"");break; case "english": setTitle(TitleType.ENGLISH ,jr.peek()!=JsonToken.NULL?jr.nextString():"");break; case "pretty": setTitle(TitleType.PRETTY ,jr.peek()!=JsonToken.NULL?jr.nextString():"");break; default:jr.skipValue();break; } if(jr.peek()==JsonToken.NULL)jr.skipValue(); } jr.endObject(); }
Example 8
Source File: VersionChecker.java From NClientV2 with Apache License 2.0 | 5 votes |
private static String[] parseVersionJson(JsonReader jr) throws IOException { String[]vars=new String[3];//ver code,body,changelog jr.beginObject(); while(jr.peek()!=JsonToken.END_OBJECT){ switch (jr.nextName()){ case "tag_name":vars[0]=jr.nextString();break; case "body":vars[1]=jr.nextString();break; case "assets": jr.beginArray(); while(jr.hasNext()){ if(vars[2]!=null){ jr.skipValue(); continue; } jr.beginObject(); while(jr.peek()!=JsonToken.END_OBJECT){ if ("browser_download_url".equals(jr.nextName())) { String url=jr.nextString(); if(url.contains("Release")) vars[2] = url; } else { jr.skipValue(); } } jr.endObject(); } jr.endArray(); break; default:jr.skipValue();break; } } return vars; }
Example 9
Source File: JSONParser.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
private static ZCashTransactionInput readTxSingleInput(JsonReader reader) throws IOException { ZCashTransactionInput input = new ZCashTransactionInput(); reader.beginObject(); while (reader.peek() != JsonToken.END_OBJECT) { String name = reader.nextName(); switch (name) { case COINBASE: input.coinbase = reader.nextString(); break; case SEQUENCE: input.sequence = reader.nextLong(); break; case TXID: input.txid = reader.nextString(); break; case VOUT: input.n = reader.nextLong(); break; case SCRIPTSIG: reader.skipValue(); break; case RETRIEVEDVOUT: input.copyDataFrom(readTxSingleOutput(reader)); break; default: reader.skipValue(); } } reader.endObject(); return input; }
Example 10
Source File: JSONParser.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
private static ZCashTransactionInput readTxSingleInput(JsonReader reader) throws IOException { ZCashTransactionInput input = new ZCashTransactionInput(); reader.beginObject(); while (reader.peek() != JsonToken.END_OBJECT) { String name = reader.nextName(); switch (name) { case COINBASE: input.coinbase = reader.nextString(); break; case SEQUENCE: input.sequence = reader.nextLong(); break; case TXID: input.txid = reader.nextString(); break; case VOUT: input.n = reader.nextLong(); break; case SCRIPTSIG: reader.skipValue(); break; case RETRIEVEDVOUT: input.copyDataFrom(readTxSingleOutput(reader)); break; default: reader.skipValue(); } } reader.endObject(); return input; }
Example 11
Source File: JSONParser.java From guarda-android-wallets with GNU General Public License v3.0 | 4 votes |
private static ZCashTransactionDetails_taddr readTx(JsonReader reader) throws IOException, IllegalStateException { ZCashTransactionDetails_taddr tx = new ZCashTransactionDetails_taddr(); if(reader.peek() != JsonToken.BEGIN_OBJECT) { throw new IOException("Cannot parse JSON"); } reader.beginObject(); while (reader.peek() != JsonToken.END_OBJECT) { String name = reader.nextName(); switch (name) { case HASH: tx.hash = reader.nextString(); break; case MAINCHAIN: tx.mainChain = reader.nextBoolean(); break; case FEE: tx.fee = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; case TYPE: tx.type = reader.nextString(); break; case SHIELDED: tx.shielded = reader.nextBoolean(); break; case INDEX: tx.index = reader.nextLong(); break; case BLOCKHASH: tx.blockHash = reader.nextString(); break; case BLOCKHEIGHT: tx.blockHeight = reader.nextLong(); break; case VERSION: tx.version = reader.nextLong(); break; case LOCKTIME: tx.locktime = reader.nextLong(); break; case TIME: tx.time = reader.nextLong(); break; case TIMESTAMP: tx.timestamp = reader.nextLong(); break; case VIN: tx.vin = readTxInputs(reader); break; case VOUT: tx.vout = readTxOutputs(reader, null); break; case VJOINSPLIT: skipJoinSplits(reader); break; case VALUE: tx.value = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; case OUTPUTVALUE: tx.outputValue = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; case SHIELDEDVALUE: tx.shieldedValue = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; default: reader.skipValue(); } } reader.endObject(); return tx; }
Example 12
Source File: JSONParser.java From guarda-android-wallets with GNU General Public License v3.0 | 4 votes |
private static ZCashTransactionOutput readTxSingleOutput(JsonReader reader) throws IOException { ZCashTransactionOutput output = new ZCashTransactionOutput(); reader.beginObject(); //output while (reader.peek() != JsonToken.END_OBJECT) { String name = reader.nextName(); switch (name) { case N: output.n = reader.nextLong(); break; case SCRIPTPUBKEY: reader.beginObject(); while (reader.peek() != JsonToken.END_OBJECT) { name = reader.nextName(); switch (name) { case ADDRESSES: reader.beginArray(); while (reader.hasNext()) { output.address = reader.nextString(); } reader.endArray(); break; case ASM: output.asm = reader.nextString(); break; case HEX: output.hex = reader.nextString(); break; case REQSIGS: output.regSigs = reader.nextLong(); break; case TYPE: output.type = reader.nextString(); break; default: reader.skipValue(); } } reader.endObject(); break; case VALUE: output.value = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; case VALUEZAT: output.value = reader.nextLong(); break; default: reader.skipValue(); } } reader.endObject(); //output end return output; }
Example 13
Source File: JSONParser.java From guarda-android-wallets with GNU General Public License v3.0 | 4 votes |
private static ZCashTransactionDetails_taddr readTx(JsonReader reader) throws IOException, IllegalStateException { ZCashTransactionDetails_taddr tx = new ZCashTransactionDetails_taddr(); if(reader.peek() != JsonToken.BEGIN_OBJECT) { throw new IOException("Cannot parse JSON"); } reader.beginObject(); while (reader.peek() != JsonToken.END_OBJECT) { String name = reader.nextName(); switch (name) { case HASH: tx.hash = reader.nextString(); break; case MAINCHAIN: tx.mainChain = reader.nextBoolean(); break; case FEE: tx.fee = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; case TYPE: tx.type = reader.nextString(); break; case SHIELDED: tx.shielded = reader.nextBoolean(); break; case INDEX: tx.index = reader.nextLong(); break; case BLOCKHASH: tx.blockHash = reader.nextString(); break; case BLOCKHEIGHT: tx.blockHeight = reader.nextLong(); break; case VERSION: tx.version = reader.nextLong(); break; case LOCKTIME: tx.locktime = reader.nextLong(); break; case TIME: tx.time = reader.nextLong(); break; case TIMESTAMP: tx.timestamp = reader.nextLong(); break; case VIN: tx.vin = readTxInputs(reader); break; case VOUT: tx.vout = readTxOutputs(reader, null); break; case VJOINSPLIT: skipJoinSplits(reader); break; case VALUE: tx.value = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; case OUTPUTVALUE: tx.outputValue = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; case SHIELDEDVALUE: tx.shieldedValue = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; default: reader.skipValue(); } } reader.endObject(); return tx; }
Example 14
Source File: JSONParser.java From guarda-android-wallets with GNU General Public License v3.0 | 4 votes |
private static ZCashTransactionOutput readTxSingleOutput(JsonReader reader) throws IOException { ZCashTransactionOutput output = new ZCashTransactionOutput(); reader.beginObject(); //output while (reader.peek() != JsonToken.END_OBJECT) { String name = reader.nextName(); switch (name) { case N: output.n = reader.nextLong(); break; case SCRIPTPUBKEY: reader.beginObject(); while (reader.peek() != JsonToken.END_OBJECT) { name = reader.nextName(); switch (name) { case ADDRESSES: reader.beginArray(); while (reader.hasNext()) { output.address = reader.nextString(); } reader.endArray(); break; case ASM: output.asm = reader.nextString(); break; case HEX: output.hex = reader.nextString(); break; case REQSIGS: output.regSigs = reader.nextLong(); break; case TYPE: output.type = reader.nextString(); break; default: reader.skipValue(); } } reader.endObject(); break; case VALUE: output.value = Double.valueOf(reader.nextDouble() * 1e8).longValue(); break; case VALUEZAT: output.value = reader.nextLong(); break; default: reader.skipValue(); } } reader.endObject(); //output end return output; }
Example 15
Source File: XulDataNode.java From starcor.xul with GNU Lesser General Public License v3.0 | 4 votes |
public static XulDataNode buildFromJson(Reader reader) { JsonReader jsonReader = new JsonReader(reader); ArrayList<XulDataNode> parseStack = new ArrayList<XulDataNode>(); XulDataNode lastDataNode = null; try { JsonToken peek; while ((peek = jsonReader.peek()) != JsonToken.END_DOCUMENT) { switch (peek) { case NAME: String nameStr = jsonReader.nextName(); if (!jsonReader.hasNext()) { continue; } switch ((peek = jsonReader.peek())) { case BEGIN_OBJECT: case BEGIN_ARRAY: if (peek == JsonToken.BEGIN_OBJECT) { jsonReader.beginObject(); } else { jsonReader.beginArray(); } lastDataNode = lastDataNode.appendChild(nameStr); parseStack.add(lastDataNode); break; case STRING: case NUMBER: lastDataNode.setAttribute(nameStr, jsonReader.nextString()); break; case BOOLEAN: lastDataNode.setAttribute(nameStr, String.valueOf(jsonReader.nextBoolean())); break; case NULL: jsonReader.nextNull(); lastDataNode.setAttribute(nameStr, null); break; } break; case BEGIN_OBJECT: case BEGIN_ARRAY: if (peek == JsonToken.BEGIN_OBJECT) { jsonReader.beginObject(); } else { jsonReader.beginArray(); } if (lastDataNode != null) { lastDataNode = lastDataNode.appendChild(String.valueOf(lastDataNode.size())); } else { lastDataNode = XulDataNode.obtainDataNode(null); } parseStack.add(lastDataNode); break; case END_OBJECT: case END_ARRAY: if (peek == JsonToken.END_OBJECT) { jsonReader.endObject(); } else { jsonReader.endArray(); } parseStack.remove(parseStack.size() - 1); if (!parseStack.isEmpty()) { lastDataNode = parseStack.get(parseStack.size() - 1); } break; default: // array switch (peek) { case STRING: case NUMBER: lastDataNode.appendChild(String.valueOf(lastDataNode.size()), jsonReader.nextString()); break; case BOOLEAN: lastDataNode.appendChild(String.valueOf(lastDataNode.size()), String.valueOf(jsonReader.nextBoolean())); break; case NULL: jsonReader.nextNull(); lastDataNode.appendChild(String.valueOf(lastDataNode.size())); break; default: jsonReader.skipValue(); break; } break; } } } catch (Exception e) { e.printStackTrace(); } return lastDataNode; }