public JSONObject toJSON(Context context,int sharedFriends,int myFriends){
  JSONObject result=new JSONObject();
  try {
    result.put(MESSAGE_ID_KEY,this.messageid);
    result.put(TEXT_KEY,this.text);
    result.put(PRIORITY_KEY,this.priority);
    result.put(HOP_KEY,this.hop + 1);
    result.put(MIN_USERS_P_HOP_KEY,this.contacts_hop);
    if (parent != null)     result.put(PARENT_KEY,this.parent);
    if (bigparent != null)     result.put(BIGPARENT_KEY,this.bigparent);
    if (timebound > 0)     result.put(TIMEBOUND_KEY,this.timebound);
    SecurityProfile profile=SecurityManager.getCurrentProfile(context);
    if (profile.isUseTrust())     result.put(TRUST_KEY,(profile.isUseTrust() ? makeNoise(trust,sharedFriends,myFriends) : 0));
    if (profile.isPseudonyms())     result.put(PSEUDONYM_KEY,this.pseudonym);
    if (profile.isShareLocation())     result.put(LATLONG_KEY,this.latlong);
  }
 catch (  JSONException e) {
    e.printStackTrace();
  }
  return result;
}

public JSONObject toJSON ( Context context , int sharedFriends , int myFriends ) { JSONObject result = new JSONObject ( ) ; try { result . put ( MESSAGE_ID_KEY , this . messageid ) ; result . put ( TEXT_KEY , this . text ) ; result . put ( PRIORITY_KEY , this . priority ) ; result . put ( HOP_KEY , this . hop + 1 ) ; result . put ( MIN_USERS_P_HOP_KEY , this . contacts_hop ) ; if ( parent != null ) result . put ( PARENT_KEY , this . parent ) ; if ( bigparent != null ) result . put ( BIGPARENT_KEY , this . bigparent ) ; if ( timebound > 0 ) result . put ( TIMEBOUND_KEY , this . timebound ) ; SecurityProfile profile = SecurityManager . getCurrentProfile ( context ) ; if ( profile . isUseTrust ( ) ) result . put ( TRUST_KEY , ( profile . isUseTrust ( ) ? makeNoise ( trust , sharedFriends , myFriends ) : 0 ) ) ; if ( profile . isPseudonyms ( ) ) result . put ( PSEUDONYM_KEY , this . pseudonym ) ; if ( profile . isShareLocation ( ) ) result . put ( LATLONG_KEY , this . latlong ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } return result ; }
convert the message into a json based on current security profile settings
