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