Passed
Pull Request — main (#56)
by Igor
02:57
created

is.JSON   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
package is
2
3
import "encoding/json"
4
5
// JSON checks that value is a valid JSON string.
6
func JSON(value string) bool {
7
	return json.Valid([]byte(value))
8
}
9
10
// UniqueStrings checks that slice of strings has unique values.
11
func UniqueStrings(values []string) bool {
12
	if len(values) == 0 {
13
		return true
14
	}
15
16
	uniques := make(map[string]struct{}, len(values))
17
18
	for _, value := range values {
19
		if _, exists := uniques[value]; exists {
20
			return false
21
		}
22
		uniques[value] = struct{}{}
23
	}
24
25
	return true
26
}
27