实时排序 firebase 控制台面板
sorting in real time firebase console panel
我想对这些数据进行排序,以便按 JSON 排列显示
这是我将自己的数据上传到实时数据库时的代码
还有一张图片我想整理一下
HashMap<String, Object> map = new HashMap<>();
map.put("1_UserName", a_name);
map.put("2_phonenumber", phonenumber);
map.put("3_Date", currentDate);
map.put("4_Time", currentTime);
map.put("5_Door_acess", check_Door_acess);
map.put("6_StructuralCabling", check_StructuralCabling);
map.put("7_Lightening", check_Lightening);
map.put("8_check_FireSystem", check_FireSystem);
map.put("9_AirConditioning", check_AirConditioning);
map.put("10_Rack_01_Network", stringcheck_Rack_01_Network);
map.put("11_PowerSourceLine1R_01", PowerSourceLine1R01);
map.put("12_PowerSourceLine2_R01", PowerSourceLineR01);
map.put("13_EarthingR01", EarthingR01);
map.put("14_ofPDUsR01", ofPDUsR01editText_String11);
map.put("15_ofOutlets_PDUR01", ofOutlets_PDUR01editText_String11);
map.put("16_Horizontal_VerticalR01", Horizontal_VerticalR01);
map.put("17_PPOSWOPPR01", PPOSWOPPR01);
FirebaseDatabase.getInstance().getReference().child("ammar").setValue(map);
和这张来自 consol 的图片
Firebase 控制台正在按预期对子键进行排序。它们按字符串值排序 lexicographically,或字典顺序。它不会使用您放在每个子项开头的数值。
如果您需要按字符串前缀对它们进行数字排序,您应该用 0 填充数值,使数字宽度相同:
map.put("01_UserName", a_name);
map.put("02_phonenumber", phonenumber);
map.put("03_Date", currentDate);
map.put("04_Time", currentTime);
map.put("05_Door_acess", check_Door_acess);
map.put("06_StructuralCabling", check_StructuralCabling);
map.put("07_Lightening", check_Lightening);
map.put("08_check_FireSystem", check_FireSystem);
map.put("09_AirConditioning", check_AirConditioning);
map.put("10_Rack_01_Network", stringcheck_Rack_01_Network);
map.put("11_PowerSourceLine1R_01", PowerSourceLine1R01);
map.put("12_PowerSourceLine2_R01", PowerSourceLineR01);
map.put("13_EarthingR01", EarthingR01);
map.put("14_ofPDUsR01", ofPDUsR01editText_String11);
map.put("15_ofOutlets_PDUR01", ofOutlets_PDUR01editText_String11);
map.put("16_Horizontal_VerticalR01", Horizontal_VerticalR01);
map.put("17_PPOSWOPPR01", PPOSWOPPR01);
如果您期望更大的数字,请使用更多的 0。
我想对这些数据进行排序,以便按 JSON 排列显示 这是我将自己的数据上传到实时数据库时的代码
还有一张图片我想整理一下
HashMap<String, Object> map = new HashMap<>();
map.put("1_UserName", a_name);
map.put("2_phonenumber", phonenumber);
map.put("3_Date", currentDate);
map.put("4_Time", currentTime);
map.put("5_Door_acess", check_Door_acess);
map.put("6_StructuralCabling", check_StructuralCabling);
map.put("7_Lightening", check_Lightening);
map.put("8_check_FireSystem", check_FireSystem);
map.put("9_AirConditioning", check_AirConditioning);
map.put("10_Rack_01_Network", stringcheck_Rack_01_Network);
map.put("11_PowerSourceLine1R_01", PowerSourceLine1R01);
map.put("12_PowerSourceLine2_R01", PowerSourceLineR01);
map.put("13_EarthingR01", EarthingR01);
map.put("14_ofPDUsR01", ofPDUsR01editText_String11);
map.put("15_ofOutlets_PDUR01", ofOutlets_PDUR01editText_String11);
map.put("16_Horizontal_VerticalR01", Horizontal_VerticalR01);
map.put("17_PPOSWOPPR01", PPOSWOPPR01);
FirebaseDatabase.getInstance().getReference().child("ammar").setValue(map);
和这张来自 consol 的图片
Firebase 控制台正在按预期对子键进行排序。它们按字符串值排序 lexicographically,或字典顺序。它不会使用您放在每个子项开头的数值。
如果您需要按字符串前缀对它们进行数字排序,您应该用 0 填充数值,使数字宽度相同:
map.put("01_UserName", a_name);
map.put("02_phonenumber", phonenumber);
map.put("03_Date", currentDate);
map.put("04_Time", currentTime);
map.put("05_Door_acess", check_Door_acess);
map.put("06_StructuralCabling", check_StructuralCabling);
map.put("07_Lightening", check_Lightening);
map.put("08_check_FireSystem", check_FireSystem);
map.put("09_AirConditioning", check_AirConditioning);
map.put("10_Rack_01_Network", stringcheck_Rack_01_Network);
map.put("11_PowerSourceLine1R_01", PowerSourceLine1R01);
map.put("12_PowerSourceLine2_R01", PowerSourceLineR01);
map.put("13_EarthingR01", EarthingR01);
map.put("14_ofPDUsR01", ofPDUsR01editText_String11);
map.put("15_ofOutlets_PDUR01", ofOutlets_PDUR01editText_String11);
map.put("16_Horizontal_VerticalR01", Horizontal_VerticalR01);
map.put("17_PPOSWOPPR01", PPOSWOPPR01);
如果您期望更大的数字,请使用更多的 0。