客户端从Kafka服务器接收事件作为字符串,是否可以从字符串中获取Json对象?就像在下面的数据我想从字符串解析public class Database extends SQLiteOpenHelper {
public static final String DATABASE_NAME="database";
public static final int DATABASE_VERSİON=1;
public static final String DATABASE_TABLE="homepage";
public static final String ROW_ID="id";
public static final String ROW_TITLE="title";
public Database(Context context) {
super(context,DATABASE_NAME, null, DATABASE_VERSİON);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table" + DATABASE_TABLE + "("
+ Database.ROW_ID + "integer primary key AUTOINCREMENT, "
+ Database.ROW_TITLE + " TEXT );");
}
@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
db.execSQL("DROP TABLE IF EXİSTS "+ DATABASE_TABLE);
onCreate(db);
}
public void addData(String title){
SQLiteDatabase db = getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(ROW_TITLE,title.trim());
db.insert(DATABASE_TABLE,null,cv);
db.close();
}
}
或我应该要求数据源发送解析对象?
ctrl.js
[object object]
数据
$scope.event = [];
$scope.event.push = data;