Create YAML string with serialization of java map
Code: "io_yaml_example.java". Programming language: Java DMelt Version 1.4. Last modified: 03/14/2016. License: Pro
https://datamelt.org/code/cache/io_yaml_example_8644.java
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


// This example shows how to serialize data to YAML format.
// You can save data to the file and restore the map.

import org.yaml.snakeyaml.*;
import java.util.*;

class io_yaml_example {

public static void main(String[] args)  {

    Map data = new HashMap();
    data.put("name", "Silenthand Olleander");
    data.put("race", "Human");
    data.put("traits", new String[] { "ONE_HAND", "ONE_EYE" });

    Yaml yaml = new Yaml();
    String output = yaml.dump(data);
    System.out.println("YAML data:\n\n\n");
    System.out.println(output);



    }
}



Ads help maintain this website.