Frite
Frite
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
it all works perfectly, thanks! i'm done with json
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
now lets get into polymorphism
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
ok this works! and runs much faster than Newtonsoft thanks guys
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
oh thanks i didn't noticed that was a string
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
'The JSON value could not be converted to System.UInt32. Path: $.layers[0].entities[0]._eid | LineNumber: 21 | BytePositionInLine: 28.' :( where line 21 : "_eid": "74122737",
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
should i get back to Newtonsoft ?
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
i'm using positive numbers
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
i didn't know about that
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
ahhh, i can't use uint ?
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
just to make things more clean
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
um, is there a way to make them readonly or private set ?
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
i removed it, first i just want it to load this
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
how should i make my objects ?
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
my code:
using System;
using System.IO;
using System.Text.Json;

namespace JSABlike;

public abstract class Ogmo
{
/* for later
public abstract class A
{
public float IN;
public float OUT;
public bool Random;
}

public class Bass : A
{
public float HOLD;
}
*/

public class LevelValues
{
public byte BPM;
}

public class Kick
{
public float IN;
public float OUT;
public bool Random;
public short PositionX;
}

public class Entity
{
public string name;
public uint id;
public uint _eid;
public ulong x;
public uint y;
public int originX;
public int originY;
public Kick values;
}

public class Layer
{
string name;
string _eid;
public int offsetX;
public int offsetY;
public byte gridCellWidth;
public byte gridCellHeight;
public uint gridCellsX;
public uint gridCellsY;
public Entity[] entities;
}

public class Level
{
public string ogmoVersion;
public uint width;
public uint height;
public int offsetX;
public int offsetY;
public LevelValues values;
public Layer[] layers;
}
}

public static class LevelReader
{
private static string Path => AppContext.BaseDirectory;

public static Ogmo.Level LoadLevel(string name)
{
string file;
using (StreamReader sr = new StreamReader(Path + name))
file = sr.ReadToEnd();

return JsonSerializer.Deserialize<Ogmo.Level>(file);
}
}
using System;
using System.IO;
using System.Text.Json;

namespace JSABlike;

public abstract class Ogmo
{
/* for later
public abstract class A
{
public float IN;
public float OUT;
public bool Random;
}

public class Bass : A
{
public float HOLD;
}
*/

public class LevelValues
{
public byte BPM;
}

public class Kick
{
public float IN;
public float OUT;
public bool Random;
public short PositionX;
}

public class Entity
{
public string name;
public uint id;
public uint _eid;
public ulong x;
public uint y;
public int originX;
public int originY;
public Kick values;
}

public class Layer
{
string name;
string _eid;
public int offsetX;
public int offsetY;
public byte gridCellWidth;
public byte gridCellHeight;
public uint gridCellsX;
public uint gridCellsY;
public Entity[] entities;
}

public class Level
{
public string ogmoVersion;
public uint width;
public uint height;
public int offsetX;
public int offsetY;
public LevelValues values;
public Layer[] layers;
}
}

public static class LevelReader
{
private static string Path => AppContext.BaseDirectory;

public static Ogmo.Level LoadLevel(string name)
{
string file;
using (StreamReader sr = new StreamReader(Path + name))
file = sr.ReadToEnd();

return JsonSerializer.Deserialize<Ogmo.Level>(file);
}
}
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
file:
{
"ogmoVersion": "3.4.0",
"width": 448,
"height": 128,
"offsetX": 0,
"offsetY": 0,
"values": {"BPM": 140},
"layers": [
{
"name": "1",
"_eid": "74127826",
"offsetX": 0,
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 28,
"gridCellsY": 8,
"entities": [
{
"name": "Kick",
"id": 8,
"_eid": "74122737",
"x": 128,
"y": 0,
"originX": 0,
"originY": 0,
"values": {"IN": 1, "OUT": 0, "Random": true, "PositionX": 0}
},
{
"name": "Kick",
"id": 9,
"_eid": "74122737",
"x": 192,
"y": 0,
"originX": 0,
"originY": 0,
"values": {"IN": 1, "OUT": 0, "Random": true, "PositionX": 0}
},
{
"name": "Kick",
"id": 10,
"_eid": "74122737",
"x": 256,
"y": 0,
"originX": 0,
"originY": 0,
"values": {"IN": 1, "OUT": 0, "Random": true, "PositionX": 0}
},
{
"name": "Kick",
"id": 11,
"_eid": "74122737",
"x": 320,
"y": 0,
"originX": 0,
"originY": 0,
"values": {"IN": 1, "OUT": 0, "Random": true, "PositionX": 0}
}
]
},
{
"name": "2",
"_eid": "74123146",
"offsetX": 0,
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 28,
"gridCellsY": 8,
"entities": []
},
{
"name": "3",
"_eid": "74121771",
"offsetX": 0,
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 28,
"gridCellsY": 8,
"entities": []
}
]
}
{
"ogmoVersion": "3.4.0",
"width": 448,
"height": 128,
"offsetX": 0,
"offsetY": 0,
"values": {"BPM": 140},
"layers": [
{
"name": "1",
"_eid": "74127826",
"offsetX": 0,
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 28,
"gridCellsY": 8,
"entities": [
{
"name": "Kick",
"id": 8,
"_eid": "74122737",
"x": 128,
"y": 0,
"originX": 0,
"originY": 0,
"values": {"IN": 1, "OUT": 0, "Random": true, "PositionX": 0}
},
{
"name": "Kick",
"id": 9,
"_eid": "74122737",
"x": 192,
"y": 0,
"originX": 0,
"originY": 0,
"values": {"IN": 1, "OUT": 0, "Random": true, "PositionX": 0}
},
{
"name": "Kick",
"id": 10,
"_eid": "74122737",
"x": 256,
"y": 0,
"originX": 0,
"originY": 0,
"values": {"IN": 1, "OUT": 0, "Random": true, "PositionX": 0}
},
{
"name": "Kick",
"id": 11,
"_eid": "74122737",
"x": 320,
"y": 0,
"originX": 0,
"originY": 0,
"values": {"IN": 1, "OUT": 0, "Random": true, "PositionX": 0}
}
]
},
{
"name": "2",
"_eid": "74123146",
"offsetX": 0,
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 28,
"gridCellsY": 8,
"entities": []
},
{
"name": "3",
"_eid": "74121771",
"offsetX": 0,
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 28,
"gridCellsY": 8,
"entities": []
}
]
}
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
my objects matchs the json file
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
with Newtonsoft it worked
54 replies
CC#
Created by Frite on 2/17/2025 in #help
✅ Opening a Json file
public static Ogmo.Level LoadLevel(string name)
{
string file;
using (StreamReader sr = new StreamReader(Path + name))
file = sr.ReadToEnd();

JsonSerializerOptions options = new JsonSerializerOptions();
options.Converters.Add(new Converter());

return JsonSerializer.Deserialize<Ogmo.Level>(file, options);
}
public static Ogmo.Level LoadLevel(string name)
{
string file;
using (StreamReader sr = new StreamReader(Path + name))
file = sr.ReadToEnd();

JsonSerializerOptions options = new JsonSerializerOptions();
options.Converters.Add(new Converter());

return JsonSerializer.Deserialize<Ogmo.Level>(file, options);
}
54 replies
CC#
Created by Frite on 1/6/2025 in #help
✅ How to use the Visual Studio memory diagnostic
yes, but the curve keep increasing, and i can watch it in my windows task manager
8 replies
CC#
Created by Frite on 1/6/2025 in #help
✅ How to use the Visual Studio memory diagnostic
how am i supose to find the memory leak
8 replies