我想使用socket将JSON中的文件发送到快速节点js服务器,我不知道该怎么做,我开始使用android代码,但我不知道如何获取它在服务器端。这是android代码:
package fr.learning_adventure.android.itac.model;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
// Created by Moez on 02/03/16.
public class Learner implements Serializable{
private final static String JSON_PSEUDO = "pseudo";
private final static String JSON_MAC = "mac";
private String pseudo;
private String mac;
public Learner(String mac, String pseudo) {
this.pseudo = pseudo;
this.mac = mac;
}
public Learner(JSONObject object) {
try {
this.pseudo = object.getString(Learner.JSON_PSEUDO);
this.mac = null;
} catch (JSONException e) {
e.printStackTrace();
}
}
public String getPseudo() {
return this.pseudo;
}
public void setPseudo(String pseudo) {
this.pseudo = pseudo;
}
public JSONObject toJSON() {
JSONObject object = new JSONObject();
try {
object.putOpt(Learner.JSON_PSEUDO,this.pseudo);
object.putOpt(Learner.JSON_MAC, this.mac);
} catch (JSONException e) {
e.printStackTrace();
}
return object;
}
}
答案 0 :(得分:0)