❔ ✅ Razor LocalStorage With Blazored.Localstorage Question

Hello! I'm retrieving data from the actual local storage and it seems to work perfectly fine when I only have 1 object. This is how my actualy object looks like in my value
"{\u0022Count\u0022:10,\u0022ID\u0022:1,\u0022dishname\u0022:\u0022Raggmunk och fl\u00E4sk\u0022,\u0022dishdiscription\u0022:\u0022Potato pancakes with pork\u0022}"
"{\u0022Count\u0022:10,\u0022ID\u0022:1,\u0022dishname\u0022:\u0022Raggmunk och fl\u00E4sk\u0022,\u0022dishdiscription\u0022:\u0022Potato pancakes with pork\u0022}"
Showing that into my blazor browser server I get this. My question is how can I retrieve more then one object in the same Key? Lets say that my Value is
"{\u0022Count\u0022:10,\u0022ID\u0022:1,\u0022dishname\u0022:\u0022Raggmunk och fl\u00E4sk\u0022,\u0022dishdiscription\u0022:\u0022Potato pancakes with pork\u0022}""{\u0022Count\u0022:10,\u0022ID\u0022:1,\u0022dishname\u0022:\u0022Raggmunk och fl\u00E4sk\u0022,\u0022dishdiscription\u0022:\u0022Potato pancakes with pork\u0022}""{\u0022Count\u0022:10,\u0022ID\u0022:1,\u0022dishname\u0022:\u0022Raggmunk och fl\u00E4sk\u0022,\u0022dishdiscription\u0022:\u0022Potato pancakes with pork\u0022}"
"{\u0022Count\u0022:10,\u0022ID\u0022:1,\u0022dishname\u0022:\u0022Raggmunk och fl\u00E4sk\u0022,\u0022dishdiscription\u0022:\u0022Potato pancakes with pork\u0022}""{\u0022Count\u0022:10,\u0022ID\u0022:1,\u0022dishname\u0022:\u0022Raggmunk och fl\u00E4sk\u0022,\u0022dishdiscription\u0022:\u0022Potato pancakes with pork\u0022}""{\u0022Count\u0022:10,\u0022ID\u0022:1,\u0022dishname\u0022:\u0022Raggmunk och fl\u00E4sk\u0022,\u0022dishdiscription\u0022:\u0022Potato pancakes with pork\u0022}"
2 Replies
mrzackattack
mrzackattackOP2y ago
This is my function that gets data from localstorage
private async Task GetData()
{
var localStorageCount = await localStorage.GetItemAsync<string>("LocalDataDishes");
//parse localStorageCount into json format
jsonString = JsonConvert.SerializeObject(localStorageCount);

// Retrieve the values
JObject json = JObject.Parse(localStorageCount);
dishName = (string)json["dishname"];
count = (int)json["Count"];
id = (int)json["ID"];
dishDescription = (string)json["dishdiscription"];
}
private async Task GetData()
{
var localStorageCount = await localStorage.GetItemAsync<string>("LocalDataDishes");
//parse localStorageCount into json format
jsonString = JsonConvert.SerializeObject(localStorageCount);

// Retrieve the values
JObject json = JObject.Parse(localStorageCount);
dishName = (string)json["dishname"];
count = (int)json["Count"];
id = (int)json["ID"];
dishDescription = (string)json["dishdiscription"];
}
!close
Accord
Accord2y ago
Closed! Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server