func (d *Document) ToMap() mapping.NamedMap {
	properties := mapping.PropertyMap{}
	namedMaps := []mapping.NamedMap{}
	namedMaps = append(namedMaps, d.Links())
	namedMaps = append(namedMaps, d.Templates())
	for _, namedMap := range namedMaps {
		properties[namedMap.Name] = namedMap.Content
	}
	return mapping.NamedMap{Name: "root", Content: properties}
}
ToMap converts Document to a "root" named map for JSON conversion.
package halforms
import (
	"net/http"
	"github.com/pmoule/go2hal/hal"
	"github.com/pmoule/go2hal/hal/mapping"
)
type InlineItem struct {
	Prompt string `json:"prompt"`
	Value  string `json:"value"`
}
type Options struct {
	Inline         []interface{}   `json:"inline"`
	Link           *hal.LinkObject `json:"link,omitempty"`
	MaxItems       string          `json:"maxItems"`
	MinItems       string          `json:"minItems"`
	PromptField    string          `json:"promptField"`
	SelectedValues []string        `json:"selectedValues"`
	ValueField     string          `json:"valueField"`
}
type Property struct {
	Name        string   `json:"name"`
	Prompt      string   `json:"prompt"`
	ReadOnly    bool     `json:"readOnly"`
	Regex       string   `json:"regex"`
	Required    bool     `json:"required"`
	Templated   bool     `json:"templated"`
	Value       string   `json:"value"`
	Cols        uint     `json:"cols"`
	Max         string   `json:"max"`
	MaxLength   string   `json:"maxLength"`
	Min         string   `json:"min"`
	MinLength   string   `json:"minLength"`
	Options     *Options `json:"options,omitempty"`
	Placeholder string   `json:"placeholder"`
	Rows        uint     `json:"rows"`
	Step        int      `json:"step"`
	Type        string   `json:"type"`
}
func NewProperty(name string) *Property {
	property := &Property{Name: name, Prompt: name, Cols: 40, Rows: 5, Type: PropertyDefaultType}
	return property
}
type Template struct {
	ContentType string      `json:"contentType"`
	Key         string      `json:"key"`
	Method      string      `json:"method"`
	Properties  []*Property `json:"properties"`
	Target      string      `json:"target"`
	Title       string      `json:"title"`
}
func NewTemplate() *Template {
	template := &Template{ContentType: jsonMediaTypeIdentifier, Key: TemplateDefaultKey, Method: http.MethodGet, Properties: []*Property{}, Title: TemplateDefaultKey}
	return template
}
type templates map[string]*Template
func (t templates) ToMap() mapping.NamedMap {
	properties := mapping.PropertyMap{}
	for _, template := range t {
		properties[template.Key] = template
	}
	return mapping.NamedMap{Name: TemplatesProperty, Content: properties}
}
type Document struct {
	links     hal.Links
	templates templates
}
func (d *Document) Links() mapping.NamedMap {
	return d.links.ToMap()
}
func (d *Document) AddLink(rel hal.LinkRelation) {
	d.links[rel.Name()] = rel
}
func (d *Document) Templates() mapping.NamedMap {
	return d.templates.ToMap()
}
func (d *Document) AddTemplate(template *Template) {
	d.templates[template.Key] = template
}