📄
Dasel
v1
v1
  • Introduction
  • Installation
    • Update
  • Use as a go package
  • Github
  • Playground
  • Usage
    • Select
    • Put
    • Put object
    • Put document
    • Delete
    • Validate
    • Flags
      • Escape HTML
      • Format
      • Multiple
      • Null
      • Merge Input Documents
    • Supported file types
  • Selectors
    • Introduction
    • Property
    • Keys and indexes
    • Index
    • Next Available Index
    • All indexes
    • Dynamic
    • Search
    • Search Optional
    • Length
    • Type
  • Notes
    • File formatting and ordering
    • Memory usage
    • Converting between formats
  • Examples
    • JQ to Dasel
    • YQ to Dasel
    • XML
    • Filter JSON API results
Powered by GitBook
On this page
  • JSON
  • Multi-document files
  • TOML
  • YAML
  • Multi-document files
  • XML
  • Data Format
  • Debugging
  • Arrays/Lists
  • CSV
  • Adding data
  • Plain
Edit on GitHub
  1. Usage

Supported file types

PreviousMerge Input DocumentsNextIntroduction

Last updated 2 years ago

Dasel attempts to find the correct parser for the given file type, but if that fails you can choose which parser to use with the -p or --parser flag.

JSON

-p json

Using .

Multi-document files

Multi-document files are decoded into an array, with [0] being the first document, [1] being the second and so on.

Once decoded, you can access them using any of the standard selectors provided by Dasel.

TOML

-p toml

Using .

YAML

-p yaml

Using .

Multi-document files

Multi-document files are decoded into an array, with [0] being the first document, [1] being the second and so on.

Once decoded, you can access them using any of the standard selectors provided by Dasel.

XML

-p xml

Data Format

XML documents within dasel are stored as a map of values.

This is just how dasel stores data and is required for the general functionality to work. An example of a simple documents representation is as follows:

<Person active="true">
  <Name main="yes">Tom</Name>
  <Age>27</Age>
</Person>
map[
  Person:map[
    -active:true
    Age:27
    Name:map[
      #text:Tom
      -main:true
    ]
  ]
]

In general this won't affect you, but on the odd occasion in specific instances it could lead to unexpected output.

Debugging

You can run select commands with the --plain flag to see the raw data that is stored within dasel. This can help you figure out the exact properties you may need to target when it isn't immediately obvious.

Arrays/Lists

Due to the way that XML is decoded, dasel can only detect something as a list if there are at least 2 items.

If you try to use list selectors (dynamic, index, append) when there are less than 2 items in the list you will get an error.

There are no plans to introduce a workaround for this but if there is enough demand it may be worked on in the future.

CSV

-p csv

Adding data

New columns will be detected and added to the end of the CSV output.

Column deletion is not supported.

Plain

-p plain

This outputs the data using fmt.Sprint(x), displaying whatever underlying value is present as a string.

Using .

If you are struggling with this please open a for support. This will also help me know when the docs aren't sufficient.

Using .

golang.org/pkg/encoding/json
github.com/pelletier/go-toml
gopkg.in/yaml.v2
github.com/clbanning/mxj
discussion
golang.org/pkg/encoding/csv