-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newtonsoft.Json.JsonSerializationException: Unexpected token while deserializing object #22
Comments
This appears to be an exception thrown from the Json.NET library. I suggest you try googling this instead, since it's not related to this library. |
And the json that's printed by the log statement is "GameInfo": {
"game": "Black Mesa",
"gamelogo": "1",
"developer": "Crowbar Collective",
"developer_url": "http://www.blackmesasource.com/",
"type": "both",
"SupportsDX8": "0",
"SupportsXbox360": "1",
"nomodels": "1",
"nocrosshair": "1",
"GameData": "bms.fgd",
"InstancePath": "bms/mapsrc/",
"FileSystem": {
"SteamAppId": "362890",
"ToolsAppId": "211",
"SearchPaths": {
"game+mod": "bms/bms_textures.vpk",
"game": "|all_source_engine_paths|hl2/hl2_misc.vpk",
"platform": "|all_source_engine_paths|platform/platform_misc.vpk",
"game+mod+mod_write+default_write_path": "|gameinfo_path|.",
"gamebin": "|gameinfo_path|bin",
"game+game_write": "bms"
}
}
} EDIT: I might be onto something here, if this isn't something that my logger changed, then it might be missing the initial "{" here? JSONlint reports the following:
I also switched from my own incomplete and short class to a generated one by quicktype.io |
Also when googling this exception the results are fairly generic and the first result even just suggests not using a class which is entirely against why im using classes in the first place Another answer suggests that it might be a bug in the parser library but i think it's something different there aswell |
I also tried a bunch of other things, like using a real simplified version with just one property public class GameInfo
{
[Newtonsoft.Json.JsonProperty("game", NullValueHandling = NullValueHandling.Ignore)]
public string Game { get; set; }
} Or wrapping it into another class because it might expect a parent? public class GameInfos
{
public GameInfo gameInfo { get; set; }
} this stuff slowly drives me insane, don't you have something like Gitter, Discord, Slack or Telegram? ^^ |
So what i gathered from the last 10 minutes looking stuff up and getting a light headache is that ".ToJson()" is just returning a jproperty which is supposedly just a part of the whole json which it would need to parse to an object? "GameInfo": { } And what i would need is { "GameInfo": { } } Is that correct? If yes, should i just slap { infront and append } ? Or is there a function to wrap a jprop into a jobj? |
It seems you were trying to deserialize a JSON file with a property as its root instead of an object. The README for this library explains the difference I suggest you convert your |
i don't think most people know what you want to tell them when they see these buzzwords xD it requires quite a bit of behind the scenes knowledge of newton's library but yeah, i'm going to |
You're right, the library assumes a certain familiarity with VDF and JSON formats. A cleaner approach might be I'm closing this issue since you seem have found a solution. Feel free to reopen if you need more help. |
The text was updated successfully, but these errors were encountered: