c# - Replace a variable in a JSON string -
i have json file containing dialogue rpg i'm making, , i'd able place players chosen name in comes up. example if player's name
public string playername = "leon";
and in json had
"npcidxxgreeting":{ "text": "yo, _____, what's up?" }
i'd able insert "leon" wherever blank space showed in dialogue json. there way this?
.net supports json converting. read in file contents , parse json information.
example
public class stats { public int attack; public string playername; public float speed; ...... } public static list<string>getjson() { using (streamreader r = new streamreader("file.json")) { string json = r.readtoend(); list<stats> stats = jsonconvert.deserializeobject<list<stats>>(json); return stats ; } }
Comments
Post a Comment