Skip to content

Feature: VCL

Аниса edited this page Sep 12, 2022 · 17 revisions

━ What's the Objective?

Vital's kit's custom lightweight confign language focussing to enhance productivity and ease of maintenance. VCL is more straightforward and feature complete unlike JSON; supports comments, nested objects (numeric & non-numeric indexes, integrated w/ vKit.Object) out of the box.

━ Format & Notations

  • [-] - Marks it as integer
  • [:] - Marks it for initialization
  • [#] - Marks it as comment
  • [-:] - Auto increments and assigns numeric index based on length of the parent object
# Creates sub-object with string index: "myIndex"
myIndex:
  indexA: "value"
  -1: "value" # String values are supported, You can surround them either by "" or ''
  -: true # Boolean values are supported
  -: 1.234 # Numeric values are supported

# Creates sub-object with numeric index: 1
-1:
  indexB: true
  -1: 1.234
  -: "value"

# Creates sub-object after auto-incrementing length of the parent object as index: 2
-: 
  indexC: "value"
  -:
    indexD: "value"
    -: "value"

━ APIs

━ vKit.vcl.encode() (Shared)

@Objective: Encodes provided object.
const string: result = vKit.vcl.encode(
  object: buffer
)

━ vKit.vcl.decode() (Shared)

@Objective: Decodes provided VCL.
const array: result = vKit.vcl.decode(
  string: buffer
)

// Result:
result: [
  ~: value, // Parsed value
  int: ref, // Reference index
  bool: isErrored // Boolean indicating whether vcl was successfully decoded
]