c# - Invalid JSON primitive when deserializing -


alright, having issue when try run application:

invalid json primitive: .

public static void reloadconfig() {     if (!file.exists("config.cfg"))     {         stringbuilder sb = new stringbuilder();          sb.append("{\r\n");         sb.append("\"admins\":[76561198214617172],\r\n");         sb.append("\"chatty\":false,\r\n");         sb.append("}");          file.writealltext("config.cfg", sb.tostring());     }     try     {         javascriptserializer jss = new javascriptserializer();         config = jss.deserialize<roles>(file.readalltext("config.cfg"));     }     catch (exception e)     {         console.writeline(e.message);         console.readkey();         reloadconfig();     } } 

and how config looks when it's generated:

{ "admins":[76561198214617172], "chatty":false, } 

as error message assume says have space in config, not have that.

and if matters use system.web.script.serialization.

you have errant comma in output after false:

{ "admins":[76561198214617172], "chatty":false, } 

should be:

{ "admins":[76561198214617172], "chatty":false } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -