From 083d451e5c6e44006e0d02423b5f7111427a7890 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Sat, 9 Aug 2014 12:16:42 -0400 Subject: [PATCH] Make JsonReader and JsonWriter our own. Drop proprietary Gson features (non-execute prefix, HTML safe chars). Don't serialize nulls by default. Add a String constructor to JsonReader. Begin to migrate JsonReader to using Okio's buffer. --- .../java/com/squareup/moshi/JsonReader.java | 523 +++++-------- .../java/com/squareup/moshi/JsonWriter.java | 32 +- .../squareup/moshi/JsonReaderPathTest.java | 40 +- .../com/squareup/moshi/JsonReaderTest.java | 687 ++++++++---------- .../com/squareup/moshi/JsonWriterTest.java | 100 ++- 5 files changed, 575 insertions(+), 807 deletions(-) diff --git a/moshi/src/main/java/com/squareup/moshi/JsonReader.java b/moshi/src/main/java/com/squareup/moshi/JsonReader.java index 93ac4de..43a979c 100644 --- a/moshi/src/main/java/com/squareup/moshi/JsonReader.java +++ b/moshi/src/main/java/com/squareup/moshi/JsonReader.java @@ -18,7 +18,9 @@ package com.squareup.moshi; import java.io.Closeable; import java.io.EOFException; import java.io.IOException; -import java.io.Reader; +import okio.Buffer; +import okio.BufferedSource; +import okio.Source; /** * Reads a JSON (RFC 4627) @@ -166,26 +168,12 @@ import java.io.Reader; * precision loss, extremely large values should be written and read as strings * in JSON. * - *

Non-Execute Prefix

- * Web servers that serve private data using JSON may be vulnerable to
Cross-site - * request forgery attacks. In such an attack, a malicious site gains access - * to a private JSON file by executing it with an HTML {@code