Good. I am working on a save editor for the game as a project, and save is in JSON. I have a small snippet returned from the actual editor after using it, and it looks like this:
{"hero":{"STR":10,"HP":33,"HT":35,"attackSkill"13,"defenseSkill":3}}
This is only a small part of the conservation. I can’t understand in my whole life how to replace this part in all salvation. I tried
I want to just replace
{"hero"{...}}
part with a new part.
How can I do it? Thank.
In addition, the pasty game saves if someone wants / needs it: http://pastebin.com/eK13cNtg
Json.NET supports "LINQ to JSON" and dynamic access, which allows you to process the entire tree dynamically without the need for POCO mapping. This has the advantage over deserializing typed objects in that additions to matching do not need to be considered for serialization with rounding.
JSON, JSON.
: . ( JSON - eww, btw! - , .)
JObject data = JObject.Parse(json); JObject hero = (JObject)data["hero"]; hero["STR"] = 42; // "god-like strength" hax; modifies the JObject json = data.ToString(); // re-serialize tree, along with modifications
dynamic type Json.NET.
dynamic
Json.NET " ", , Dictionary/JObject.
POCO - - / ; , , , "" POCO.
#, , . , , ( JSON, ), , JSON ( Javascript).
Javascript
var myObj = {'no.kidding':'This is valid'}; alert(myObj['no.kidding']);
, " ".
, , , , .
: http://json.org/ - #, , , .
(, , ), , , '.' '_' ( - ) , , . - , , .
Json to C # is all that. This does not work, because for some the reason the game developer decided that half of the fields would be the class names from his game, for example. "Com.whatever.whatever": 1. This is an analyzer concern.
I could not recreate the problem. This works for me.
dynamic response = Newtonsoft.Json.Linq.JObject.Parse(json); var jsonNewHero = "{'hero':{'STR':10,'HP':33,'HT':35,'attackSkill': 13,'defenseSkill':3}}"; dynamic newHero = Newtonsoft.Json.Linq.JObject.Parse(jsonNewHero); response.hero = newHero.hero; var newJson = Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented);
Work .NET Fiddle: http://dotnetfiddle.net/PKPQC1
PS: Using the latest version of Newtonsoft Json version 6.0.1
Source: https://habr.com/ru/post/1529621/More articles:hovering only when overflowing - cssDoes OBJC_ASSOCIATION_ASSIGN mean atomic or non-atomic? - objective-cUnable to post space in database: postgreSQL and Codeigniter - phpWhat is the advantage of using gradle in Android development? - androidAssociative array in javascript using the / tuple pair as a multi-valued key / index - javascriptHow to use setClob () in PreparedStatement inJDBC - javausing CLOB in java throwing exception - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1529624/authentication-to-box-in-a-c-desktop-application-using-the-box-windows-sdk-v2-library&usg=ALkJrhgdndrDVjrB_fFtxIIp4n4YHVNmQQRunning code execution in a global space compared to a function in Javascript - javascriptHow to import several databases at once through PhpMyAdmin? - mysqlAll Articles