Dasel
v3
v3
  • Getting started
    • Introduction
    • Installation
    • Concepts
      • Expressions
      • Branches
  • Syntax
    • Whitespace
    • Types/Literals
    • String concatenation
    • Arrays/slices
    • Objects/maps
    • Conditionals
    • Spread
    • Coalesce
  • Input/Output
    • Read/Write formats
    • Stdin
    • Stdout
    • Variables
    • Read/Writer flags
  • Functions
    • add
    • min
    • max
    • reverse
    • toString
    • toInt
    • toFloat
    • typeOf
    • map
    • filter
    • sortBy
    • parse
    • base64e
    • base64d
Powered by GitBook
On this page
  • Defining a new map
  • Creating a map using existing values
  • Adding new fields to a map
  1. Syntax

Objects/maps

An object/map is a set of key value properties.

Defining a new map

{"greeting": "hello"}

Creating a map using existing values

{"foo": "bar", "name": "Tom"}. // Just so you can see the input
{
    "baz": foo,
    name // Shorthand for "name": name
}

Adding new fields to a map

We can utilise the spread ... operator here.

Set "name" = "Tom" regardless of what is in the map already:

{
  $this...,
  "name": "Tom"
}

Set "name" = "Tom" only if it doesn't already exist in the map:

{
    "name": "Tom",
    $this...
}
PreviousArrays/slicesNextConditionals

Last updated 7 months ago