Files can be quickly loaded using a static class called KspData:

var obj = KspData.LoadFile(@"C:\games\KSP_win\saves\manitcor\persistent.sfs");
var vessels = obj["GAME"]["FLIGHTSTATE"]["VESSEL"];

once done you have a list of vessel objects. Notice the name of the properites matches the names found in the persistent.sfs. CASE IS IMPORTANT. If the file uses an all caps name, you must use an all caps name in your code. The object you get back from Load file is a Json.NET JObect and the example I show to get vessels is just one of many, see Json.Net documentation for all the ways you can play with the data coming out of LoadFile (http://james.newtonking.com/projects/json/help/).

With a collection of vessels you can access individual vessels just like any other collection:

var vesselName = vessels[0]["name"];

Note the use of ".Value". As these objects are JObjects you need to call the Value property on any field in order to get its actual value stored in the save file.

You can also use Linq and lamdas to filter your data:

var myVessels = vessels.Where(v => v["name"].Contains("GPS"));

To update Data:

KspData.SaveFile("PATH", obj);

From here you can use the KerbalData API to convert or save the changes to a file.

I will have more details, examples and updates as time goes on I also plan on making some of my own tools but I see so many creative ideas here I want to enable folks and keep people from spending so much time just trying to get a read on the data.
EXAMPLES:

WPF Bound DataGrid https://kerbaldata.codeplex.com/downloads/get/598729

Last edited Jan 17, 2013 at 6:29 AM by Manitcor, version 4

Comments

No comments yet.