- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经关注了一些具有相同上下文的问题,但我仍然没有找到理解或发现此错误的方法。我正在尝试将数据发送到我的 Firebase 实时数据库。付款的总费用,在我的购物车中列出和用户名,但我仍然收到此错误。
com.google.firebase.database.DatabaseException: No properties to serialize found on class com.urbanx.urbaninsure.model.RequestDelivery
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper.<init>(com.google.firebase:firebase-database@@19.1.0:530)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.loadOrCreateBeanMapperForClass(com.google.firebase:firebase-database@@19.1.0:312)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.serialize(com.google.firebase:firebase-database@@19.1.0:166)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertToPlainJavaTypes(com.google.firebase:firebase-database@@19.1.0:60)
at com.google.firebase.database.DatabaseReference.setValueInternal(com.google.firebase:firebase-database@@19.1.0:282)
at com.google.firebase.database.DatabaseReference.setValue(com.google.firebase:firebase-database@@19.1.0:159)
at com.urbanx.urbaninsure.InsurancePayment$1.onClick(InsurancePayment.java:255)
我的支付类
public class Payment extends AppCompatActivity implements View.OnClickListener {
LinearLayout InsurancePaymentLayout, MethodPaymentLayout, MpesaLayout, CreditCardLayout, EazzyPayLayout,
mpesaLayout, CreditBarLayout, EazzyPayBarLayout, PaymentStatementLayout,LAddress,
DeclinedPaymentStatementLayout,CompleteLayout, DeliveryLayout, hdCardLayout, cardLayout;
TextView tvCostStatement,tvCost, tvPay, tvAddress,etvAddress ;
TextView tvSerial, tvStroke, tvExpire, tvCardNumber;
RadioButton rbMpesa, rbCard, rbEazzy;
ProgressBar pbComplete;
Button bComplete, bDelivery, bPay;
ImageView ivMpesa, ivCredit;
EditText etCcn, etYear, etMonth, cd1, cd2, cd3, cd4;
List<ProposalDetails> cart = new ArrayList<>();
DatabaseHelper myDb;
CartAdapter adapter;
FirebaseDatabase database;
DatabaseReference requests;
CoordinatorLayout layout;
DatabaseReference mCustomerDatabase;
private FirebaseAuth mAuth;
private String totalPrice;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_insurance_payment);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
layout = (CoordinatorLayout)findViewById(R.id.layout);
LAddress = (LinearLayout)findViewById(R.id.LAddress);
etvAddress = (TextView) findViewById(R.id.etvAddress);
tvAddress = (TextView)findViewById(R.id.tvAddress);
bComplete = (Button)findViewById(R.id.bComplete);
bComplete.setOnClickListener(this);
cardLayout = (LinearLayout)findViewById(R.id.cardLayout);
cd1 = (EditText)findViewById(R.id.cd1);
cd2 = (EditText)findViewById(R.id.cd2);
cd3 = (EditText)findViewById(R.id.cd3);
cd4 = (EditText)findViewById(R.id.cd4);
ivCredit = (ImageView)findViewById(R.id.ivCredit);
hdCardLayout = (LinearLayout)findViewById(R.id.hdCardLayout);
tvCardNumber = (TextView)findViewById(R.id.tvCardNumber);
tvSerial = (TextView)findViewById(R.id.tvSerial);
tvStroke = (TextView)findViewById(R.id.tvStroke);
tvExpire =(TextView)findViewById(R.id.tvExpire);
etCcn = (EditText)findViewById(R.id.etCcn);
etMonth = (EditText)findViewById(R.id.etMonth);
etYear = (EditText)findViewById(R.id.etYear);
bPay = (Button)findViewById(R.id.bPay);
ivMpesa = (ImageView)findViewById(R.id.ivMpesa);
pbComplete = (ProgressBar)findViewById(R.id.pbComplete);
rbMpesa = (RadioButton)findViewById(R.id.rbMpesa);
rbMpesa.setOnClickListener(this);
rbCard = (RadioButton)findViewById(R.id.rbCard);
rbCard.setOnClickListener(this);
rbEazzy = (RadioButton)findViewById(R.id.rbEazzy);
rbEazzy.setOnClickListener(this);
tvCostStatement = (TextView)findViewById(R.id.tvCostStatement);
totalPrice = getIntent().getStringExtra("totalPrice");
tvCost = (TextView)findViewById(R.id.tvCost);
tvCost.setText(totalPrice);
tvCost.setText(totalPrice);
myDb = new DatabaseHelper(this);
adapter = new CartAdapter(cart,this);
database = FirebaseDatabase.getInstance();
requests = database.getReference("OrderRequests");
tvPay = (TextView)findViewById(R.id.tvPay);
InsurancePaymentLayout = (LinearLayout)findViewById(R.id.InsurancePaymentLayout);
MethodPaymentLayout = (LinearLayout)findViewById(R.id.MethodPaymentLayout);
MpesaLayout = (LinearLayout)findViewById(R.id.MpesaLayout);
CreditCardLayout = (LinearLayout)findViewById(R.id.CreditCardLayout);
EazzyPayLayout = (LinearLayout)findViewById(R.id.EazzyPayLayout);
mpesaLayout = (LinearLayout)findViewById(R.id.mpesaLayout);
mpesaLayout.setVisibility(View.GONE);
CreditBarLayout = (LinearLayout)findViewById(R.id.CreditBarLayout);
CreditBarLayout.setVisibility(View.GONE);
EazzyPayBarLayout = (LinearLayout)findViewById(R.id.EazzyPayBarLayout);
EazzyPayBarLayout.setVisibility(View.GONE);
PaymentStatementLayout = (LinearLayout)findViewById(R.id.PaymentStatementLayout);
PaymentStatementLayout.setVisibility(View.GONE);
DeclinedPaymentStatementLayout = (LinearLayout)findViewById(R.id.DeclinedPaymentStatementLayout);
CompleteLayout = (LinearLayout)findViewById(R.id.CompleteLayout);
CompleteLayout.setVisibility(View.VISIBLE);
DeliveryLayout = (LinearLayout)findViewById(R.id.DeliveryLayout);
bDelivery = (Button)findViewById(R.id.bDelivery);
bDelivery.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.rbMpesa:
if (rbMpesa.isChecked()){
rbCard.setChecked(false);
rbEazzy.setChecked(false);
mpesaLayout.setVisibility(View.VISIBLE);
CreditBarLayout.setVisibility(View.GONE);
EazzyPayBarLayout.setVisibility(View.GONE);
}
break;
case R.id.rbCard:
if (rbCard.isChecked()){
rbMpesa.setChecked(false);
rbEazzy.setChecked(false);
mpesaLayout.setVisibility(View.GONE);
CreditBarLayout.setVisibility(View.VISIBLE);
EazzyPayBarLayout.setVisibility(View.GONE);
}
break;
case R.id.rbEazzy:
if (rbEazzy.isChecked()){
rbMpesa.setChecked(false);
rbCard.setChecked(false);
mpesaLayout.setVisibility(View.GONE);
CreditBarLayout.setVisibility(View.GONE);
EazzyPayBarLayout.setVisibility(View.VISIBLE);
}
break;
case R.id.bComplete:
showAlertDialog();
break;
case R.id.bDelivery:
startActivity(new Intent(this, DeliveryActivity.class));
break;
}
}
private void showAlertDialog() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("Final step!");
alertDialog.setMessage("Enter your delivery location: ");
LayoutInflater inflater = LayoutInflater.from(this);
View destination_layout = inflater.inflate(R.layout.enter_address,null);
final EditText etAddress = destination_layout.findViewById(R.id.edtAddress);
alertDialog.setView(destination_layout);
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final android.app.AlertDialog waitingDialog = new SpotsDialog(InsurancePayment.this,"Placing ");
waitingDialog.show();
if (TextUtils.isEmpty(etAddress.getText().toString()))
{
Snackbar.make(layout,"Please enter delivery location", Snackbar.LENGTH_SHORT)
.show();
return;
}
String address = etAddress.getText().toString();
DeliveryRequest requestDelivery = new DeliveryRequest();
requestDelivery.setFirstNameProposer("am");
requestDelivery.setLastNameProposer("");
requestDelivery.setAddress("address");
// String json = gson.toJson(requestDelivery);
String requestId = requests.push().getKey();
requests.child(requestId)
.setValue(requestDelivery);
myDb.deleteAllInsurance();
myDb.deleteAllInsurance();
LAddress.setVisibility(View.VISIBLE);
etvAddress.setText(address);
waitingDialog.dismiss();
Toast.makeText(InsurancePayment.this,"Thank your, Order placed",Toast.LENGTH_SHORT).show();
PaymentStatementLayout.setVisibility(View.VISIBLE);
CompleteLayout.setVisibility(View.GONE);
pbComplete.setVisibility(View.VISIBLE);
DeliveryLayout.setVisibility(View.VISIBLE);
}
});
alertDialog.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
dialogInterface.dismiss();
}
});
alertDialog.show();
}
@Override
public void onBackPressed() {
if ((pbComplete.getVisibility() == View.VISIBLE)&&(DeliveryLayout.getVisibility()==View.VISIBLE)) {
// Its visible
} else {
Intent openProposalForm = new Intent(InsurancePayment.this, Cart.class);
startActivity(openProposalForm);
finish();
// Either gone or invisible
}
}
@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
}
我的 RequestDelivery 类
public class DeliveryRequest implements Serializable {
public String firstNameProposer, lastNameProposer,address;
public DeliveryRequest() {
}
public String getFirstNameProposer() {
return firstNameProposer;
}
public void setFirstNameProposer(String firstNameProposer) {
this.firstNameProposer = firstNameProposer;
}
public String getLastNameProposer() {
return lastNameProposer;
}
public void setLastNameProposer(String lastNameProposer) {
this.lastNameProposer = lastNameProposer;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
最佳答案
我以前没有使用过 firebase 数据库,但我使用过其他提供 JSON 响应的 API,或者我向服务器发送了 json 响应。因此,当您获取/发送 JSON 响应时,您需要告诉 Java 如何使用 @SerializedName
读取它。因此,例如,如果您收到这样的 json 响应:
{
phone:"12345678",
__total:"1000",
... ...
}
我认为在这种情况下,您需要像这样更改 RequestDelivery
类:
class RequestDelivery{
@SerializedName("phone") /* here this 'phone' is the string that is exactly in the json response*/
public String phone;
@SerializedName("__total") /* put __total because it is in my sample json. You change it according to your actual json response */
public String total;
... ... ...
}
请谷歌了解更多关于您应该为列表做什么的详细信息(代码中的提案详细信息)。我希望这有效。祝你好运。
关于java - firebase.database.DatabaseException : No properties to serialize found on class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58899548/
目前我有以下内容: $.ajax({ type: 'POST', url: this.action, data: $(this).serialize(), }); 这工作正常,
目前我有以下内容: $.ajax({ type: 'POST', url: this.action, data: $(this).serialize(), }); 这很好用,但
我知道什么是序列化,但对我来说,这是一个无法描述其含义的术语。 为什么我们称序列化为序列化?将对象转换为原始数据(以及膨胀/反序列化,就此而言)有什么意义?谁创造了这个术语,为什么? 最佳答案 它可能
是否可以将数据结构(使用 boost::serialization)序列化为字符串变量或缓冲区(而不是磁盘上的文件)? 最佳答案 当然,让它在stringstream上完成工作。 关于serializ
假设我有以下类型定义,它依赖于常量来指示记录成员的向量长度: type point_t is record x: std_logic_vector(X_WIDTH-1 downto 0);
我尝试序列化一个向量和一个 map 容器,并通过 cout 输出它们的值。然而,我很难理解boost输出的含义。我的代码如下所示: #include #include #include #
我正在尝试将序列化功能添加到我的 Rust 结构之一。这是一个日历事件,看起来像这样: #[derive(PartialEq, Clone, Encodable, Decodable)] pub st
正如主题所暗示的那样,在将大量数据序列化到文件时,我遇到了 boost::serialization 的一个小问题。问题在于应用程序的序列化部分的内存占用大约是被序列化对象内存的 3 到 3.5 倍。
在搜索解决方案时,我得到了 this和 this但我不清楚这个概念,所以无法实现:(。当我尝试更新数据库中的值(特别是日期时间对象)时会发生此错误。以下是我正在使用的代码:- var upd
我收到以下错误, 模板对象不可迭代 def get_AJAX(request, id): data = serializers.serialize("json", Template.objec
由于方便,我正在考虑对我的所有数据 i/o 使用 serialize() 和 deserialize()。但是,我不想在 Julia 更新中被不可读的文件所困扰。 serialize() 和 dese
我有一个通常使用 JMS Serializer 包序列化的实体。我必须在序列化中添加一些不驻留在实体本身中但通过一些数据库查询收集的字段。 我的想法是创建一个自定义对象,用实体字段填充字段并添加自定义
我正在尝试使用 XmlParser 从 xml 文件中删除和添加标签。以下是我在使用“grails run-app”命令部署的 grails 应用程序中执行时运行良好的代码块: def parser
我正在使用 MRUnit 测试 MultipleOutputs。测试用例失败并显示以下消息。 java.lang.ClassCastException: org.apache.hadoop.io.se
本文整理了Java中com.jme3.network.serializing.serializers.ZIPSerializer类的一些代码示例,展示了ZIPSerializer类的具体用法。这些代码
我有一个处理草图,需要与 USB 设备建立 2 个连接。我无法提前判断哪个设备是 USB0 哪个是 USB1。 (不是我至少知道) 其中一台设备发出问候语,另一台设备根本不回答。因此,我编写了带有简单
我在下面有这个代码,我来自 this forum我遵循了。它对我不起作用,但他们声称代码很好。我已经尝试了几种字符串比较方法,例如 string.equals(string)和标准==运营商,仍然没有
当我尝试调用特定的 Web 服务方法时,我收到“Unspecified error”。使用 XMLSpy 我发现参数对象还没有被序列化。 在生成的序列化程序源中,我注意到以下几行: if (!need
在 Rust 中编写 NEAR 智能合约,我的编译器似乎要求通过 API 发送的对象具有 Serialize trait,以及存储在区块链中的对象 BorshSerialize和 BorshDeser
我正在尝试 Kotlin 序列化。按照说明进行设置后,我得到了 Unresolved reference: serializer使用此代码构建错误: val serializer : KSeriali
我是一名优秀的程序员,十分优秀!