All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.koushikdutta.async.parser.JSONArrayParser Maven / Gradle / Ivy

Go to download

Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads.

There is a newer version: 3.1.0
Show newest version
package com.koushikdutta.async.parser;

import com.koushikdutta.async.DataEmitter;
import com.koushikdutta.async.DataSink;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.future.Future;
import com.koushikdutta.async.future.TransformFuture;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * Created by koush on 5/27/13.
 */
public class JSONArrayParser implements AsyncParser {
    @Override
    public Future parse(DataEmitter emitter) {
        return new StringParser().parse(emitter)
        .then(new TransformFuture() {
            @Override
            protected void transform(String result) throws Exception {
                setComplete(new JSONArray(result));
            }
        });
    }

    @Override
    public void write(DataSink sink, JSONArray value, CompletedCallback completed) {
        new StringParser().write(sink, value.toString(), completed);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy