// FromJSON converts incoming JSON into a Node.
555960
func FromJSON(r io.Reader, mhType uint64, mhLen int) (*Node, error) {
	var m interface{}
	err := json.NewDecoder(r).Decode(&m)
	if err != nil {
		return nil, err
	}

	obj, err := convertToCborIshObj(m)
	if err != nil {
		return nil, err
	}

	return WrapObject(obj, mhType, mhLen)
}
619890
func ToJSON(data []byte) ([]byte, error) {
	if hasJSONPrefix(data) {
		return data, nil
	}
	return yaml.YAMLToJSON(data)
}
1081274
func (c *Client) FromString(targetPath, content string) (resource.Resource, error) {
	return c.rs.ResourceCache.GetOrCreate(resources.CACHE_OTHER, targetPath, func() (resource.Resource, error) {
		return c.rs.NewForFs(
			c.rs.FileCaches.AssetsCache().Fs,
			resources.ResourceSourceDescriptor{
				LazyPublish: true,
				OpenReadSeekCloser: func() (hugio.ReadSeekCloser, error) {
					return hugio.NewReadSeekerNoOpCloserFromString(content), nil
				},
				RelTargetFilename: filepath.Clean(targetPath)})

	})

}
879273
func FromReader(reader io.Reader, options ...Options) (string, error) {
	newReader, err := bom.NewReaderWithoutBom(reader)
	if err != nil {
		return "", err
	}
	doc, err := html.Parse(newReader)
	if err != nil {
		return "", err
	}
	return FromHTMLNode(doc, options...)
}
1149035
func (c Client) WithJSON(body interface{}) Client {
	c = c.WithHeader("Content-Type", "application/json")
	c.json = &body
	return c
}
1071938
func (t *Table) ToJSON(w io.Writer) {
	t.mu.RLock()
	defer t.mu.RUnlock()
	w.Write([]byte(`{ "bindings": [`))

	if len(t.AvailableBindings) > 0 {
		w.Write([]byte(`"`))
		w.Write([]byte(strings.Join(t.AvailableBindings, `", "`)))
		w.Write([]byte(`"`))
	}

	w.Write([]byte(`], "rows": [`))

	rc := len(t.Data)
	for _, r := range t.Data {
		if len(r) > 0 {
			w.Write([]byte(`{ `))

			cc := len(t.AvailableBindings)
			for _, k := range t.AvailableBindings {
				if k != "" {
					c := r[k]
					w.Write([]byte(`"`))
					w.Write([]byte(k))
					w.Write([]byte(`": {"`))

					if c.S != nil {
						w.Write([]byte(`string": "`))
						w.Write([]byte(strings.Replace(*c.S, `"`, `\"`, -1)))
					} else if c.N != nil {
						w.Write([]byte(`node": "`))
						w.Write([]byte(strings.Replace(c.N.String(), `"`, `\"`, -1)))
					} else if c.P != nil {
						w.Write([]byte(`pred": "`))
						w.Write([]byte(strings.Replace(c.P.String(), `"`, `\"`, -1)))

					} else if c.L != nil {
						w.Write([]byte(`lit": "`))
						w.Write([]byte(strings.Replace(c.L.String(), `"`, `\"`, -1)))

					} else if c.T != nil {
						w.Write([]byte(`anchor": "`))
						w.Write([]byte(strings.Replace(c.T.Format(time.RFC3339Nano), `"`, `\"`, -1)))
					}

					w.Write([]byte(`"}`))
					if cc > 1 {
						w.Write([]byte(`,`))
					}
					w.Write([]byte(` `))
				}
				cc--
			}
			w.Write([]byte(` }`))
			if rc > 1 {
				w.Write([]byte(`, `))
			}
		}
		rc--
	}

	w.Write([]byte(`] }`))
}
684601
func FromJSON(jsonBytes []byte) ([]byte, error) {
	var j EncodedCaddyfile
	var result string

	err := json.Unmarshal(jsonBytes, &j)
	if err != nil {
		return nil, err
	}

	for sbPos, sb := range j {
		if sbPos > 0 {
			result += "\n\n"
		}
		for i, key := range sb.Keys {
			if i > 0 {
				result += ", "
			}
			//result += standardizeScheme(key)
			result += key
		}
		result += jsonToText(sb.Body, 1)
	}

	return []byte(result), nil
}
808252
func (h *Header) EncodeJSON() (string, error) {
	data, err := json.Marshal(h.header)
	return string(data), err
}
375214
func FromChain(endSink Sink, sinks ...MiddlewareConstructor) Sink {
	for i := len(sinks) - 1; i >= 0; i-- {
		endSink = sinks[i](endSink)
	}
	return endSink
}
705930
func From(in []byte) ([]byte, error) {
	tr, err := fromCp949()
	if err != nil {
		return nil, err
	}

	_, out, err := tr.Translate(in)
	if err != nil {
		return nil, err
	}

	return out, nil
}
651470
func (m *MailYak) fromHeader() string {
	if m.fromName == "" {
		return fmt.Sprintf("From: %s\r\n", m.fromAddr)
	}

	return fmt.Sprintf("From: %s <%s>\r\n", m.fromName, m.fromAddr)
}
277445
func ToJSON(in interface{}) (string, error) {
	s, err := toJSONBytes(in)
	if err != nil {
		return "", err
	}
	return string(s), nil
}
445258
func (s *DeleteByQueryService) From(from int) *DeleteByQueryService {
	s.from = &from
	return s
}
1046219
func (c *Container) FromDisk() error {
	jsonSource, err := os.Open(c.StatePath())
	if err != nil {
		return err
	}
	defer jsonSource.Close()

	dec := json.NewDecoder(jsonSource)
	return dec.Decode(c.state)
}
93592
func FromObject(obj runtime.Object) error {
	switch t := obj.(type) {
	case *unversioned.Status:
		return &StatusError{*t}
	}
	return &UnexpectedObjectError{obj}
}
920125
func (pdfg *PDFGenerator) ToJSON() ([]byte, error) {

	jpdf := &jsonPDFGenerator{
		TOC:            pdfg.TOC,
		Cover:          pdfg.Cover,
		GlobalOptions:  pdfg.globalOptions,
		OutlineOptions: pdfg.outlineOptions,
	}

	for _, p := range pdfg.pages {
		jp := jsonPage{
			InputFile: p.InputFile(),
		}
		switch tp := p.(type) {
		case *Page:
			jp.PageOptions = tp.PageOptions
		case *PageReader:
			jp.PageOptions = tp.PageOptions
		}
		if p.Reader() != nil {
			buf, err := ioutil.ReadAll(p.Reader())
			if err != nil {
				return nil, err
			}
			jp.Base64PageData = base64.StdEncoding.EncodeToString(buf)
		}
		jpdf.Pages = append(jpdf.Pages, jp)
	}
	return json.Marshal(jpdf)
}
1253779
func FromError(err error) (s *Status, ok bool) {
	if err == nil {
		return &Status{Code: codes.OK}, true
	}
	if s, ok := err.(*Status); ok {
		return s, true
	}
	return nil, false
}