在Firebase中将孩子名字的大写字母作为首字母

编程入门 行业动态 更新时间:2024-10-27 13:24:25
本文介绍了在Firebase中将孩子名字的大写字母作为首字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用Order对象将数据推送到Firebase,问题是我想要每个子名称的首字母大写.我将属性定义为投诉",但在Firebase中,该属性仍显示为投诉",我不知道该怎么做.

I push data to Firebase using Order object, the question is I want the first letter of every child name capital. I defined the property like "Complain" but in Firebase it still shows as "complain", I dont know how to make it.

Firebase的当前结构:

The current structure of the Firebase:

我想要的结构:

我这样定义属性:

@Data public class Order implements Serializable { @SerializedName("Complain") private String Complain; public Order() { Complain = ""; } public String getComplain() { return Complain; } public void setComplain(String complain) { Complain = complain; } }

我这样将数据推送到Firebase:

I push data to Firebase like this:

Map<String, Object> map = new HashMap<>(); map.put(orderSavePath, order); reference.updateChildren(map).addOnCompleteListener(listener);

推荐答案

Firebase JSON序列化名称由注释PropertyName .

The Firebase JSON serialization name is controlled by the annotation PropertyName.

public class Order implements Serializable { private String Complain; public Order() { Complain = ""; } @PropertyName("Complain") public String getComplain() { return Complain; } @PropertyName("Complain") public void setComplain(String complain) { Complain = complain; } }

注释必须同时在getter和setter上.或者,您可以只使用公共字段并将类简化为:

The annotation needs to be on both the getter and the setter. Alternatively you can just use public fields and reduce the class to:

public class Order { @PropertyName("Complain") public String Complain; }

更多推荐

在Firebase中将孩子名字的大写字母作为首字母

本文发布于:2023-10-23 19:36:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521816.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大写字母   中将   首字母   名字   孩子

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!