Skip to content

Latest commit

 

History

History
81 lines (56 loc) · 1.72 KB

README.md

File metadata and controls

81 lines (56 loc) · 1.72 KB

KV-Reader


Key-Value file reader.
This is a simple key-value structure file parser, which can be used for various purposes, such as configuration files, do whatever you want.

Install

For Unity, download package from here.

For Dll, download from here.

K-V File

The typical K-V file is as follows:

// Comment line1
// Comment line2
// Comment line3

KEY          VALUE1
KEY1         VALUE2

This tiny library can parse almost any file :

image

image

Usage

Open KV Reader Tool by clicking Tools/KV Reader

image

// Reader Parse
Reader reader = new Reader();

// Parse
reader.ParseFromString(File.text);

// Print
Console.WriteLine(reader["KEY"][0]);
string test = @"
// Comment
KEY1 VALUE1
KEY2 VALUE2
";

// Parse
var data = Reader.ParseDocumentFromString(test, out List<string> headComments);

// Read
Console.WriteLine(data[1].Key + " " + data[1].Value);

// Change Value
data[1].Key = "KEY_CHANGE";
data[1].Value = "VALUE_CHANGE";

// Format
var result = Reader.FormatDocumentToString(data, headComments);

// Print Result
Console.WriteLine(result);