user940016
user940016

Reputation: 2948

JSON library in Android: Missing InputStream constructor

I'm trying to use the Android JSON library, but the version is old and there's no constructor in JSONObject that accepts an InputStream, just a String. I can't read all the contents of the stream to the string because it's longer than the maximum length. Is there a way to add data to the JSONObject after the constructor? If not, how can I upgrade the version in Android?

Upvotes: 0

Views: 201

Answers (2)

SpdyMx
SpdyMx

Reputation: 34

Try to use my open source library: http://code.google.com/p/android-json-rpc/ There is no Input Stream but direct call to JSON REST service.

You can also override the JSONObject class, like this:

package com.m4bce.loisirs_ch;

import java.io.IOException;
import java.io.InputStream;

import org.json.JSONObject;

public class JSONObjectStream extends JSONObject {

    public JSONObjectStream(InputStream is) throws IOException {
        super();

        // your code here
    }

}

I hope this help.

Upvotes: 0

jeet
jeet

Reputation: 29199

Why not you use, Gson Api, its a third party api by Google. Check following links:

http://code.google.com/p/google-gson/

https://sites.google.com/site/gson/gson-user-guide

Upvotes: 1

Related Questions