jsons.go

 1package jsons
 2
 3// Merge merges inputs into a single json.
 4//
 5// It detects the format by file extension, or try all mergers
 6// if no extension found
 7//
 8// Accepted Input:
 9//
10//   - `string`: path to a local file
11//   - `[]string`: paths of local files
12//   - `[]byte`: content of a file
13//   - `[][]byte`: content list of files
14//   - `io.Reader`: content reader
15//   - `[]io.Reader`: content readers
16func Merge(inputs ...interface{}) ([]byte, error) {
17	return NewMerger().Merge(inputs...)
18}
19
20// MergeAs loads inputs of the specific format and merges into a single json.
21//
22// Accepted Input:
23//
24//   - `string`: path to a local file
25//   - `[]string`: paths of local files
26//   - `[]byte`: content of a file
27//   - `[][]byte`: content list of files
28//   - `io.Reader`: content reader
29//   - `[]io.Reader`: content readers
30func MergeAs(format Format, inputs ...interface{}) ([]byte, error) {
31	return NewMerger().MergeAs(format, inputs...)
32}