public JSONObject convertToJson ( ) { JSONObject buoJsonModel = new JSONObject ( ) ; try { // Add all keys in plane format initially. All known keys will be replaced with corresponding data type in the following section JSONObject metadataJsonObject = metadata_ . convertToJson ( ) ; Iterator < String > keys = metadataJsonObject . keys ( ) ; while ( keys . hasNext ( ) ) { String key = keys . next ( ) ; buoJsonModel . put ( key , metadataJsonObject . get ( key ) ) ; } if ( ! TextUtils . isEmpty ( title_ ) ) { buoJsonModel . put ( Defines . Jsonkey . ContentTitle . getKey ( ) , title_ ) ; } if ( ! TextUtils . isEmpty ( canonicalIdentifier_ ) ) { buoJsonModel . put ( Defines . Jsonkey . CanonicalIdentifier . getKey ( ) , canonicalIdentifier_ ) ; } if ( ! TextUtils . isEmpty ( canonicalUrl_ ) ) { buoJsonModel . put ( Defines . Jsonkey . CanonicalUrl . getKey ( ) , canonicalUrl_ ) ; } if ( keywords_ . size ( ) > 0 ) { JSONArray keyWordJsonArray = new JSONArray ( ) ; for ( String keyword : keywords_ ) { keyWordJsonArray . put ( keyword ) ; } buoJsonModel . put ( Defines . Jsonkey . ContentKeyWords . getKey ( ) , keyWordJsonArray ) ; } if ( ! TextUtils . isEmpty ( description_ ) ) { buoJsonModel . put ( Defines . Jsonkey . ContentDesc . getKey ( ) , description_ ) ; } if ( ! TextUtils . isEmpty ( imageUrl_ ) ) { buoJsonModel . put ( Defines . Jsonkey . ContentImgUrl . getKey ( ) , imageUrl_ ) ; } if ( expirationInMilliSec_ > 0 ) { buoJsonModel . put ( Defines . Jsonkey . ContentExpiryTime . getKey ( ) , expirationInMilliSec_ ) ; } buoJsonModel . put ( Defines . Jsonkey . PublicallyIndexable . getKey ( ) , isPublicallyIndexable ( ) ) ; buoJsonModel . put ( Defines . Jsonkey . LocallyIndexable . getKey ( ) , isLocallyIndexable ( ) ) ; buoJsonModel . put ( Defines . Jsonkey . CreationTimestamp . getKey ( ) , creationTimeStamp_ ) ; } catch ( JSONException ignore ) { } return buoJsonModel ; }
Convert the BUO to corresponding Json representation