Give this a try, Alama
@page "/fetchdata"
@using System.IO
@using Newtonsoft.Json
<h1>JSON Sprites Sheet Parser</h1>
<p>@val</p>
<button @onclick="@(() => LoadJson())">Show Json</button>
@code
{
string val;
private void LoadJson()
{
using (StreamReader r = new StreamReader("Shared/Skining/sprites_sheet.json"))
{
string json = r.ReadToEnd();
var obj = JsonConvert.DeserializeObject(json);
var jObject = Newtonsoft.Json.Linq.JObject.Parse(obj.ToString());
val = jObject.ToString();
}
}
}
And your JSON
{
"frames": {
"Bitmap 1": {
"frame": {
"x": 0,
"y": 1936,
"w": 100,
"h": 100
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 100,
"h": 100
},
"sourceSize": {
"w": 100,
"h": 100
}
},
"Bitmap 10": {
"frame": {
"x": 366,
"y": 1882,
"w": 51,
"h": 51
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 51,
"h": 51
},
"sourceSize": {
"w": 51,
"h": 51
}
},
"Bitmap 11": {
"frame": {
"x": 240,
"y": 1815,
"w": 68,
"h": 73
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 68,
"h": 73
},
"sourceSize": {
"w": 68,
"h": 73
}
}
}
}
Posted 3 years ago
by selliott