2016-03-24 21 views
-1

我想用JSON將文件發送到使用套接字的快速節點js服務器,我不知道該怎麼做,我開始使用android代碼,但我不知道如何在服務器端獲取它。這裏是android代碼:如何在JSON之間發送和接收文件在android和節點之間js

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

你的問題太寬了.. –

回答

相關問題