Я использую Firebase, я делаю запрос и получаю данные. Затем охватывая JSON
, после этого мой JSON
порядок данных изменился, не в чем проблема, я не хочу, чтобы порядок изменился.
Какое решение сделать тот же заказ здесь мои данные
//Query Applied
pathref.queryOrderedByKey().queryStarting(atValue: fromItemKey).queryLimited(toFirst: UInt(paginationCount)).observe(.value, with: { (snapshot) in {
print(" json obj=====",snapshot.value )
// all order is correct
let jsonData = try JSONSerialization.data(withJSONObject: bizOfferingsSnapshot.value as Any, options: .prettyPrinted)
let offeringJson = try JSON(data: jsonData)
// here order is changed
print(" json obj=====",offeringJson )
}
образец для данных моментального снимка
Optional({
20 = {
bizOfferingsHeaderTypeThree = {
headerText = Fruits;
indexOrder = 1;
isVisible = 1;
};
bizOfferingsID = "Fruits_20";
description = "";
imageStoragePathList = (
"MUSKMELON.png"
);
isVisible = 1;
itemQunatitySelected = 0;
itemRetailInfo = {
quantityPrice = (
{
discountPrice = 0;
isEditable = 0;
quantity = 1000;
quantitySelected = 1000;
regularPrice = 18;
}
);
units = GRAMS;
};
masterImage = 0;
primaryText = Muskmelon;
totalCountQunatity = 0;
vegNonVegInfoEnum = NONE;
};
21 = {
bizOfferingsHeaderTypeThree = {
headerText = Fruits;
indexOrder = 1;
isVisible = 1;
};
bizOfferingsID = "Fruits_21";
description = "";
imageStoragePathList = (
"ORANGES_IMPORTED.png"
);
isVisible = 1;
itemQunatitySelected = 0;
itemRetailInfo = {
quantityPrice = (
{
discountPrice = 0;
isEditable = 0;
quantity = 500;
quantitySelected = 500;
regularPrice = "117.5";
}
);
units = GRAMS;
};
masterImage = 0;
primaryText = "Oranges Imported";
totalCountQunatity = 0;
vegNonVegInfoEnum = NONE;
};
22 = {
bizOfferingsHeaderTypeThree = {
headerText = Fruits;
indexOrder = 1;
isVisible = 1;
};
bizOfferingsID = "Fruits_22";
description = "";
imageStoragePathList = (
"MUSK_MELON_MADHUMATHI.png"
);
isVisible = 1;
itemQunatitySelected = 0;
itemRetailInfo = {
quantityPrice = (
{
discountPrice = 0;
isEditable = 0;
quantity = 1000;
quantitySelected = 1000;
regularPrice = 39;
}
);
units = GRAMS;
};
masterImage = 0;
primaryText = "Musk Melon Madhumathi";
totalCountQunatity = 0;
vegNonVegInfoEnum = NONE;
};
23 = {
bizOfferingsHeaderTypeThree = {
headerText = Fruits;
indexOrder = 1;
isVisible = 1;
};
bizOfferingsID = "Fruits_23";
description = "";
imageStoragePathList = (
"APPLE_FUZI.png"
);
isVisible = 1;
itemQunatitySelected = 0;
itemRetailInfo = {
quantityPrice = (
{
discountPrice = 0;
isEditable = 0;
quantity = 500;
quantitySelected = 500;
regularPrice = "104.5";
}
);
units = GRAMS;
};
masterImage = 0;
primaryText = "Apple Fuzi";
totalCountQunatity = 0;
vegNonVegInfoEnum = NONE;
};
24 = {
bizOfferingsHeaderTypeThree = {
headerText = Fruits;
indexOrder = 1;
isVisible = 1;
};
bizOfferingsID = "Fruits_24";
description = "";
imageStoragePathList = (
"APPLE_ROYAL_GALA_PACK_OF_4_NOS.png"
);
isVisible = 1;
itemQunatitySelected = 0;
itemRetailInfo = {
quantityPrice = (
{
discountPrice = 0;
isEditable = 0;
quantity = 1;
quantitySelected = "0.1";
regularPrice = 99;
}
);
units = PIECES;
};
masterImage = 0;
primaryText = "Apple Royal Gala Pack of 4 Nos";
totalCountQunatity = 0;
vegNonVegInfoEnum = NONE;
};
25 = {
bizOfferingsHeaderTypeThree = {
headerText = Fruits;
indexOrder = 1;
isVisible = 1;
};
bizOfferingsID = "Fruits_25";
description = "";
imageStoragePathList = (
"Fruits/KIWI.png"
);
isVisible = 1;
itemQunatitySelected = 0;
itemRetailInfo = {
quantityPrice = (
{
discountPrice = 0;
isEditable = 0;
quantity = 1;
quantitySelected = "0.1";
regularPrice = 25;
}
);
units = PIECES;
};
masterImage = 0;
primaryText = Kiwi;
totalCountQunatity = 0;
vegNonVegInfoEnum = NONE;
};
образец для данных после преобразования в JSON
данныепорядок изменяется
{
"24" : {
"masterImage" : 0,
"imageStoragePathList" : [
"APPLE_ROYAL_GALA_PACK_OF_4_NOS.png"
],
"itemRetailInfo" : {
"quantityPrice" : [
{
"regularPrice" : 99,
"isEditable" : false,
"discountPrice" : 0,
"quantitySelected" : 0.10000000000000001,
"quantity" : 1
}
],
"units" : "PIECES"
},
"bizOfferingsID" : "Fruits_24",
"itemQunatitySelected" : 0,
"totalCountQunatity" : 0,
"primaryText" : "Apple Royal Gala Pack of 4 Nos",
"isVisible" : true,
"description" : "",
"bizOfferingsHeaderTypeThree" : {
"indexOrder" : 1,
"headerText" : "Fruits",
"isVisible" : true
},
"vegNonVegInfoEnum" : "NONE"
},
"29" : {
"masterImage" : 0,
"imageStoragePathList" : [
"THAI_GUAVA_IMPORTED.png"
],
"itemRetailInfo" : {
"quantityPrice" : [
{
"regularPrice" : 59.5,
"isEditable" : false,
"discountPrice" : 0,
"quantitySelected" : 500,
"quantity" : 500
}
],
"units" : "GRAMS"
},
"bizOfferingsID" : "Fruits_29",
"itemQunatitySelected" : 0,
"totalCountQunatity" : 0,
"primaryText" : "Thai Guava (Imported)",
"isVisible" : true,
"description" : "",
"bizOfferingsHeaderTypeThree" : {
"indexOrder" : 1,
"headerText" : "Fruits",
"isVisible" : true
},
"vegNonVegInfoEnum" : "NONE"
},
"25" : {
"masterImage" : 0,
"imageStoragePathList" : [
"Fruits\/KIWI.png"
],
"itemRetailInfo" : {
"quantityPrice" : [
{
"regularPrice" : 25,
"isEditable" : false,
"discountPrice" : 0,
"quantitySelected" : 0.10000000000000001,
"quantity" : 1
}
],
"units" : "PIECES"
},
"bizOfferingsID" : "Fruits_25",
"itemQunatitySelected" : 0,
"totalCountQunatity" : 0,
"primaryText" : "Kiwi",
"isVisible" : true,
"description" : "",
"bizOfferingsHeaderTypeThree" : {
"indexOrder" : 1,
"headerText" : "Fruits",
"isVisible" : true
},
"vegNonVegInfoEnum" : "NONE"
},
"28" : {
"masterImage" : 0,
"imageStoragePathList" : [
"TAMARIND_SWEET_PACK_OF_250_G.png"
],
"itemRetailInfo" : {
"quantityPrice" : [
{
"regularPrice" : 90,
"isEditable" : false,
"discountPrice" : 0,
"quantitySelected" : 0.10000000000000001,
"quantity" : 1
}
],
"units" : "PIECES"
},
"bizOfferingsID" : "Fruits_28",
"itemQunatitySelected" : 0,
"totalCountQunatity" : 0,
"primaryText" : "Tamarind Sweet Pack of 250 g",
"isVisible" : true,
"description" : "",
"bizOfferingsHeaderTypeThree" : {
"indexOrder" : 1,
"headerText" : "Fruits",
"isVisible" : true
},
"vegNonVegInfoEnum" : "NONE"
},
"22" : {
"masterImage" : 0,
"imageStoragePathList" : [
"MUSK_MELON_MADHUMATHI.png"
],
"itemRetailInfo" : {
"quantityPrice" : [
{
"regularPrice" : 39,
"isEditable" : false,
"discountPrice" : 0,
"quantitySelected" : 1000,
"quantity" : 1000
}
],
"units" : "GRAMS"
},
"bizOfferingsID" : "Fruits_22",
"itemQunatitySelected" : 0,
"totalCountQunatity" : 0,
"primaryText" : "Musk Melon Madhumathi",
"isVisible" : true,
"description" : "",
"bizOfferingsHeaderTypeThree" : {
"indexOrder" : 1,
"headerText" : "Fruits",
"isVisible" : true
},
"vegNonVegInfoEnum" : "NONE"
},
"26" : {
"masterImage" : 0,
"imageStoragePathList" : [
"CUSTARD_APPLE.png"
],
"itemRetailInfo" : {
"quantityPrice" : [
{
"regularPrice" : 44.5,
"isEditable" : false,
"discountPrice" : 0,
"quantitySelected" : 500,
"quantity" : 500
}
],
"units" : "GRAMS"
},
"bizOfferingsID" : "Fruits_26",
"itemQunatitySelected" : 0,
"totalCountQunatity" : 0,
"primaryText" : "Custard Apple",
"isVisible" : true,
"description" : "",
"bizOfferingsHeaderTypeThree" : {
"indexOrder" : 1,
"headerText" : "Fruits",
"isVisible" : true
},
"vegNonVegInfoEnum" : "NONE"
}
некоторое время я получаю [ноль, ноль, ноль, ноль, ноль, ноль, ноль, ноль, ноль, ноль, ноль, {словарь}] почему я получаю ноль, даже снимок10 предметов после передачи в ison, получая 20 предметов с первыми 10, равными нулю, нуль