- Home /
JsonUtility.fromJson won't work with german Umlauts ä ü ö
Hey Guys, I've been programming a questionnaire creation tool using json files as specification. It works fine with english but as soon as I add those damn german Umlauts (ä, ö ,ü), fromJson just spits out null. I've tried to read up on encoding but could'nt solve my problem on my own. Any help is much appreciated Here is my basic setup:
public List<TextAsset> jsonFiles;
private Questionnaire questionnaire;
.
questionnaire = JsonUtility.FromJson<Questionnaire>(jsonFiles[i].ToString());
.
[Serializable]
public class Questionnaire
{
public string title;
public string id;
public Question[] questions;
}
[Serializable]
public class Question
{
public string questiontype;
public string instructions;
public bool multipleChoice;
public string id;
public int numberButtons;
public string question;
}
Where questionnaire returns null when confronted with Umlaut-filled .json. Can anyone help me out? Thanks in advance!
Answer by elPitto · Jan 23, 2019 at 12:34 PM
Oh nevermind. I just found my mistake: I didn't save the file in unicode encoding but in western european (as defaulted by Visual Studio). For anyone having the same stupid problem: 'save as' and choose 'save with encoding', then choose your encoding. Cheers mates
PS: Encoding working with JsonUtility is UTF 8
This worked too when I tried to import a csv-file into my project. Thanks!