Skip to content
Sign upLog in
← Back to Community

Problens with System.Text.Json [C#]

Profile icon
gabrielbertoldo

for some reason the line of code using System.text.Json; wont work saying: error CS0234: The type or namespace name Json' does not exist in the namespaceSystem.Text'.Are you missing an assembly reference?

using System;
using System.IO;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

class Empacotar
{
public static void GeraArquivo()
{
string jsonString;
jsonString = JsonSerializer.Serialize(jogador);
File.WriteAllText(fileName, jsonString);
}
}

Voters
Profile icon
JithuJoshy
Profile icon
djseebs
Profile icon
a5rocks
Profile icon
gabrielbertoldo
Comments
hotnewtop
Profile icon
a5rocks

Can you post your repl?

Profile icon
gabrielbertoldo

@a5rocks
Sure thing

Profile icon
a5rocks

@gabrielbertoldo
Hmm, not sure why, you might need to wait until someone who knows c# comes by. I tried looking it up, nothing there, and there seemed to be an alternative called System.Json which doesn't work either :(

Profile icon
gabrielbertoldo

@a5rocks
Ok thanks !

Profile icon
gabrielbertoldo

@a5rocks
i think i should chance to xml looks like Json isn't working for some reason XS

Profile icon
SixBeeps

@gabrielbertoldo
I know C# pretty well. Could you re-link the repl?

Profile icon
gabrielbertoldo

@SixBeeps
Sure

using System;
using System.IO;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

class Empacotar
{
public static void GeraArquivo()
{
string jsonString;
jsonString = JsonSerializer.Serialize(jogador);
File.WriteAllText(fileName, jsonString);
}
}

Profile icon
SixBeeps

@gabrielbertoldo
Do you have an actual Repl set up with that code?

Profile icon
gabrielbertoldo

@SixBeeps
i insert the repl entire code on the question i think you meant that right ?

Profile icon
SixBeeps

@gabrielbertoldo
No, I mean the link to the editor where I can run your code

Profile icon
gabrielbertoldo

@SixBeeps
So i believe is this one https://repl.it/@gabrielbertoldo/RPG-Arena
sorry i'm new to foruns