LogoLogo
  • Internet Object 1.0
  • Internet Object
    • Abstract
    • The Poetic Principles of Internet Object
    • Objectives
    • Introducing Internet Object
  • The Structure
    • Internet Object Document
      • Header
      • Data Sections
    • Structural Elements
      • Structural Characters and Literals
      • Literals
      • Other Special Characters
      • Whitespaces
    • Values Representations
      • Objects
      • Arrays
      • Strings
        • Open Strings
        • Regular Strings
        • Raw Strings
      • Numeric Values
        • Number
        • BigInt
        • Decimal
        • Special Numeric Integer Formats
          • Hexadecimal
          • Octal
          • Binary
        • NaN and Infinity
      • Binary
      • Date and Time
      • Booleans
      • Nulls
    • Comments
    • Encoding
  • The Collections
    • Collection
    • Creating Collection
    • Collection Rules
    • Data Streaming
  • The Definitions
    • Definitions
    • Variables
    • Complex Schema
  • Schema Definition Language
    • Internet Object Schema
    • The structure
    • Data Types
      • Any
      • String
        • String Derived Types
          • Email
          • URL
          • Date
          • Time
          • DateTime
      • Number
        • Derived Types
          • int
          • byte
          • int16
          • int32
      • Object
      • Array
      • Bool
    • Dynamic Schema
    • Is Object, a MemberDef or a Schema?
  • Other
    • Best Practices
    • FAQs
    • Contributors
    • License
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
Export as PDF
  1. The Definitions

Definitions

PreviousData StreamingNextVariables

Last updated 10 months ago

Was this helpful?

Apart from the schema, the IO document header can have definitions. The definitions allow you to define schema, variables, metadata, and much more. In essence, the definitions are the collection of key-value pairs, with the following structure.

The Defination Structure

Whitespaces surrounding the tokens, keys, and values are optional.

The definition must start with a tidal symbol (~ U+007E) followed by a key-value pair. The key-value pair must be separated by a colon (: U+003A).

Element

Unicode

Details

~

U+007E

Tilde - Starts the definition

:

U+003A

Colon - Key and Value Separator

Key

N/A

Value

N/A

WS

WhiteSpace Char

0 or more white-space character

A definition walkthrough

Simple definitions

Simple definitions such as meta-data declaration can be written as shown in the code snippet below.

# The result meta-data
~ pageSize: 1
~ currentPage: 1
~ totalPages: 1
~ recordCount: 2
~ success: T
---
# The data
~ John Done, 25, {Bond Street, New York, NY}
~ Jane Doe, 20, {Bond Street, New York, NY}

Value and Schema definitions

Any value defined in the definition section can be used as a variable. The dollar $ prefix can be used to declare schema and/or consume the variable value. If the key starts with $ a sign the variable will be treated as a schema and handled likewise.

# Variables and schema definitions
~ y: yes # value var
~ n: no  # value var
~ $address: {street, city, state} # schema var
~ $schema: {name, age, $address, ready:{string, choices:[$y, $n]} # schema var
---
~ John Done, 25, {Bond Street, New York, NY}, $y
~ Jane Doe, 20, {Bond Street, New York, NY}, $y

Here in the code snippet, y: yes and n: no are used as value definition similarly keys in the schema prefixed with $ sign represents schema definitions.

An Internet object document may only contain the header section and not a data section. In such a case, the header section must be separated from the data section by a data separator "---".

The string key, as defined in the .

The values as defined in the .

String section
Values section