Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Json Deserialize on Android doesn't work for me

$
0
0

@Thomas1 wrote:

Hi, I try to make an tiny android project & try to deserialize a Json file, but each time I have this exception :
"Unhandled Exception:
System.IO.DirectoryNotFoundException: Could not find a part of the path "/Platformer/Json/Level/document.json"."
( You can find the project here : https://www.dropbox.com/s/ot4kkor0j27kt8q/Platformer.zip?dl=0 )

The json file called "document.json" :
{
"creator": "Thomas",
"name": "Niveau 1"
}

I also make an Json test project for a Window Project using this code, and it work fine.

protected LevelJSON GetLevelJSON(string psFileName)
{
LevelJSON myLevelJSON;
Debug.WriteLine("TEST :");
Debug.WriteLine(File.ReadAllText(psFileName));
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(File.ReadAllText(psFileName))))
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(LevelJSON));
myLevelJSON = (LevelJSON)ser.ReadObject(stream);
}
return myLevelJSON;
}

And finally, there is one thing that confuses me, when I add the reference for the Json (for use : using System.Runtime.Serialization; ), the PC version & Android version isn't the same. ( Maybe it doesn't work because of that, but I have no idea ... )
:
( I'm French, so my visual studio is in French :slight_smile: )

Also, I use in the both projects besides "using System.Runtime.Serialization;" :
using System.Text;
using System.Text;

I spent my weekend to try different things and I'm stuck, I have no idea what is wrong.
Thank to reply if you have any idea about that.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles