Using KON in Your Program - Mrcarrot1/KarrotObjectNotation GitHub Wiki

KON is relatively easy to use in a program.

Data can be read from files using the KONParser class. Pass a string argument into KONParser.Parse to obtain the KONNode your KON file represents. The method KONParser.TryParse is also available.

A KONNode contains a number of collections. The Dictionary Values within a node contains all of the values in a node. As of KON 1.0, values are of the type IKONValue, which must be converted to KONValue<T> to be used. This allows for non-string data types. The List Children contains all of a node's subnodes. The List Arrays contains all of the KONArrays within a node.

As of KON 0.1.3, the KONArray class is enumerable, allowing its items to be accessed with foreach.

To write a KON node to a file, the KONWriter class is used. The most useful method in this class is KONWriter.Write, which takes a node and returns its string representation, which may be subsequently written to disk.

As of KON 0.1.1, the parsing and writing methods are non-static, which means that an object reference is required to use them. This was done in order to provide better options for parsing.

Parsing and writing options currently consist of the ability to change what the parser and writer do with the case of a given string in a KON file. You may wish to import all node titles as uppercase, for instance. This can be easily changed by changing the value of the read mode or write mode variable for node names, keys, or values. This can be done at initialization or after the object has been created. For a full list of options, see Parser Options and Writer Options.