@@ -21,7 +21,15 @@ func ReadTupleFile(fileName string) ([]client.ClientTupleKey, error) {
2121 var tuples []client.ClientTupleKey
2222
2323 switch path .Ext (fileName ) {
24- case ".json" , ".yaml" , ".yml" :
24+ case ".json" :
25+ err = yaml .Unmarshal (data , & tuples )
26+ if err != nil {
27+ err = parseTuplesFromJSONL (data , & tuples )
28+ }
29+ if err == nil && len (tuples ) == 0 {
30+ err = clierrors .EmptyTuplesFileError ("json" )
31+ }
32+ case ".yaml" , ".yml" :
2533 err = yaml .Unmarshal (data , & tuples )
2634 if err == nil && len (tuples ) == 0 {
2735 err = clierrors .EmptyTuplesFileError (strings .TrimPrefix (path .Ext (fileName ), "." ))
@@ -38,3 +46,26 @@ func ReadTupleFile(fileName string) ([]client.ClientTupleKey, error) {
3846
3947 return tuples , nil
4048}
49+
50+ func parseTuplesFromJSONL (data []byte , tuples * []client.ClientTupleKey ) error {
51+ lines := strings .Split (strings .TrimSpace (string (data )), "\n " )
52+ for index , line := range lines {
53+ trimmed := strings .TrimSpace (line )
54+ if trimmed == "" {
55+ continue
56+ }
57+
58+ var tuple client.ClientTupleKey
59+ if err := yaml .Unmarshal ([]byte (trimmed ), & tuple ); err != nil {
60+ return fmt .Errorf ("failed to parse tuple on line %d: %w" , index + 1 , err )
61+ }
62+
63+ * tuples = append (* tuples , tuple )
64+ }
65+
66+ if len (* tuples ) == 0 {
67+ return clierrors .EmptyTuplesFileError ("json" )
68+ }
69+
70+ return nil
71+ }
0 commit comments