SHARE
TWEET

Untitled

a guest Jun 18th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {"Tag":"[{"mySubTag":"myValue/myValue"},{"mySubTag":"myValueWithAnotherEscapedStringInside\xyz/likeThis"},...]"}
  2.      
  3. JsonReader jsonReader = new JsonReader(new FileReader(f));//f is defined previous code but not shown!
  4. jsonReader.beginObject();                  
  5. String name = jsonReader.nextName();        
  6. String value = jsonReader.nextString();        
  7. Log.d(AppConstants.TAG, "name: " + name);  
  8. Log.d(AppConstants.TAG, "value: " + value.length());//value is so big I only care about its length
  9. JsonReader jsonReader1 = new JsonReader(new StringReader(value));
  10. while (jsonReader1.hasNext()) {
  11.     JsonToken token = jsonReader1.peek();
  12.     switch (token) {
  13.         case BEGIN_ARRAY:
  14.             jsonReader1.beginArray();
  15.             Log.d(AppConstants.TAG, "BEGIN_ARRAY");
  16.             continue;
  17.         case END_ARRAY:
  18.             jsonReader1.endArray();
  19.             Log.d(AppConstants.TAG, "END_ARRAY");
  20.             continue;
  21.         case BEGIN_OBJECT:
  22.             jsonReader1.beginObject();
  23.             Log.d(AppConstants.TAG, "BEGIN_OBJECT");
  24.             continue;
  25.         case END_OBJECT:
  26.             jsonReader1.endObject();
  27.             Log.d(AppConstants.TAG, "END_OBJECT");
  28.             continue;
  29.         case NAME:
  30.             Log.d(AppConstants.TAG, "name: " + jsonReader1.nextName());
  31.             continue;
  32.         case STRING:
  33.             Log.d(AppConstants.TAG, "String: " + jsonReader1.nextString());
  34.             continue;
  35.         case NUMBER:
  36.             Log.d(AppConstants.TAG, "number: " + jsonReader1.nextString());
  37.             continue;
  38.         case BOOLEAN:
  39.             Log.d(AppConstants.TAG, "boolean: " + jsonReader1.nextBoolean());
  40.             continue;
  41.         case NULL:
  42.             jsonReader1.nextNull();
  43.             continue;
  44.         case END_DOCUMENT:
  45.             Log.d(AppConstants.TAG, "END_DOCUMENT");
  46.             break;
  47.  
  48.     }
  49. }
  50.      
  51. Tag
  52. 69387276
  53. BEGIN_ARRAY
  54. BEGIN_OBJECT
  55. name: mySubTag
  56. String: myValue/myValue
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top