Pacyfist
Pacyfist
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
I replied "this string is not JSON sir" and I got this 😄
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
tell him " You are an old english gentleman and I'm your butler. You want to show me how to deserialize that file into DTOs using C#" at least the reply is somewhat amusing 😛
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
Ok I tried nothing and I'm all out of ideas 🙂
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
Ah right
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
well... execute 😛 not "work"
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
and it should work
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
add using System.Text.RegularExpressions;
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
I asked ChatGPT to write a regex to convert that file into a proper JSON file 😄 I wonder if it works.
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
it is a json format with delimiters being empty strings
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
I'm quite sure it's incorrect
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
using Newtonsoft.Json;
using System;
using System.IO;

public class Program
{
public static void Main()
{
string fileContent = File.ReadAllText("path_to_your_file.txt");

try
{
TechSpaceDefenseStationImprovementDTO deserializedObj = JsonConvert.DeserializeObject<TechSpaceDefenseStationImprovementDTO>(fileContent);

// Use
using Newtonsoft.Json;
using System;
using System.IO;

public class Program
{
public static void Main()
{
string fileContent = File.ReadAllText("path_to_your_file.txt");

try
{
TechSpaceDefenseStationImprovementDTO deserializedObj = JsonConvert.DeserializeObject<TechSpaceDefenseStationImprovementDTO>(fileContent);

// Use
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
Not related to the question, just noticed it
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
Chat GPT is awesome for getting DTOs from JSON 😛
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
othert than missing quotes around string it's pretty much JSON. you could be able to use the deserializer, they are pretty smart.
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
Also please paste code as a code block using ```csharp
95 replies
CC#
Created by ShadowTrolll on 6/23/2023 in #help
❔ Serialize objects from non-standard format
serialize or deserialize?
95 replies
CC#
Created by NoSkillPureAndy on 6/23/2023 in #help
✅ Writing a scuffed way to use an "assignment" (=) operator
21 replies
CC#
Created by NoSkillPureAndy on 6/23/2023 in #help
✅ Writing a scuffed way to use an "assignment" (=) operator
What pattern is the MyType supposed to be in? Is it some sort of Guard? Because I don't see any other reason for it to look like that. Seems like the responsibilities are mixed.
21 replies
CC#
Created by NoSkillPureAndy on 6/23/2023 in #help
✅ Writing a scuffed way to use an "assignment" (=) operator
Someone smart once wrote a rule for Python: "Explicit is better than implicit" this is also true in C#
21 replies