Project

kvn

0.0
No commit activity in last 3 years
No release in over 3 years
KVN key/value notation converter & parser
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

= 0.1.0
 Project Readme

Lines of Code Maintainability Build Status Coverage Status Downloads

KVN (kĕ'vĭn)

Key/Value Notation

name:kvn; pronunciation:kĕ'vĭn; summary:Key/Value Notation;

Similar to JSON but narrower in scope. Represents basic key/value data structures as legible strings. Useful when working with limited storage options to capture complex data in a single field.

Rules

  • Key & value are delimited with a colon :
  • Key/value pairs are delimited with a semicolon ;
  • Colons & semicolons are reserved & are prohibited in keys & values
  • Data structures should be flat— 1 level deep, no nesting
  • Keys & values are limited to primitive types
    • Boolean
    • String
    • Numeric
  • Keys are sorted alphabetically

Examples

Convert a Hash to a KVN string

data = { d: "example with whitespace", a: true, c: "example", b: 1, e: nil }
Kvn::Converter.new(data).convert
# => "a:true; b:1; c:example; d:example with whitespace; e:null;"

Parse a KVN string into a Hash

value = "a:true; b:1; c:example; d:example with whitespace; e:null;"
Kvn::Parser.new(value).parse
# => {"a"=>true, "b"=>1, "c"=>"example", "d"=>"example with whitespace", "e"=>nil}