GithubHelp home page GithubHelp logo

yaml-old's Introduction

Yaml

Build Status Build status Coverage Status License Version

yaml is a parser for the YAML data serialization language written in Scala. yaml is moving towards compliance with YAML Version 1.2, but is still in early development.

Examples

Here are some example code snippets showing how to use the parser.

Short Example

This is from example 2.10 from chapter 2 of the spec.

import xyz.hyperreal.yaml._

object Example extends App {

  val result =
    read(
      """
        |---
        |hr:
        |  - Mark McGwire
        |  # Following node labeled SS
        |  - &SS Sammy Sosa
        |rbi:
        |  - *SS # Subsequent occurrence
        |  - Ken Griffey
      """.stripMargin
    )

  println( result )

}

Output

List(Map(hr -> List(Mark McGwire, Sammy Sosa), rbi -> List(Sammy Sosa, Ken Griffey)))

Longer Example

This is from example 2.27 from chapter 2 of the spec.

---
invoice: 34843
date   : 2001-01-23
bill-to: &id001
    given  : Chris
    family : Dumars
    address:
        lines: |
            458 Walkman Dr.
            Suite #292
        city    : Royal Oak
        state   : MI
        postal  : 48046
ship-to: *id001
product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments:
    Late afternoon is best.
    Backup contact is Nancy
    Billsmer @ 338-4338.
...

Output

The output from the above example is equivalent the result of the following Scala snippet.

val bill_to =
  Map(
    "given" -> "Chris",
    "family" -> "Dumars",
    "address" ->
      Map(
        "lines" -> "458 Walkman Dr.\nSuite #292\n",
        "city" -> "Royal Oak",
        "state" -> "MI",
        "postal" -> 48046
      )
  )

  Map(
    "invoice" -> 34843,
    "date" -> LocalDate.parse("2001-01-23"),
    "bill-to" -> bill_to,
    "ship-to" -> bill_to,
    "product" ->
      List(
        Map(
          "sku" -> "BL394D",
          "quantity" -> 4,
          "description" -> "Basketball",
          "price" -> 450.00
        ),
        Map(
          "sku" -> "BL4438H",
          "quantity" -> 1,
          "description" -> "Super Hoop",
          "price" -> 2392.00
        )
      ),
    "tax" -> 251.42,
    "total" -> 4443.52,
    "comments" -> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."
  )

Usage

Use the following definition to use Yaml in your Maven project:

<repository>
  <id>hyperreal</id>
  <url>https://dl.bintray.com/edadma/maven</url>
</repository>

<dependency>
  <groupId>xyz.hyperreal</groupId>
  <artifactId>yaml</artifactId>
  <version>0.2</version>
</dependency>

Add the following to your build.sbt file to use yaml in your SBT project:

resolvers += "Hyperreal Repository" at "https://dl.bintray.com/edadma/maven"

libraryDependencies += "xyz.hyperreal" %% "yaml" % "0.2"

Building

Requirements

  • Java 11
  • SBT 1.2.8+
  • Scala 2.13.0+

Clone and Assemble Executable

git clone git://github.com/edadma/yaml.git
cd yaml
sbt assembly

The command sbt assembly also runs all the unit tests.

License

ISC © 2019 Edward A. Maxedon, Sr.

yaml-old's People

Contributors

edadma avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

yaml-old's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.