strictyaml icon indicating copy to clipboard operation
strictyaml copied to clipboard

Support request: Sequence of sequences

Open fkromer opened this issue 4 years ago • 5 comments

Does StriclYaml support nested sequences like e.g. seq_of_seqs

seq_of_seqs:
  -
    - "a"
    - "b"
  -
    - 1
    - 2

I could not find a corresponding section in the sequences docs.

fkromer avatar Sep 17 '19 11:09 fkromer

Hi. You should be able to Seq(Seq(Str())), no?

crdoconnor avatar Sep 21 '19 14:09 crdoconnor

Yep, it works:

In [1]: from strictyaml import Seq, Str, load                                                                                                                                                                      

In [2]: load(""" 
   ...: - 
   ...:   - 1 
   ...:   - 2 
   ...:   - 3 
   ...: - 
   ...:   - f 
   ...:   - 5 
   ...:   - 6 
   ...: """, Seq(Seq(Str())))                                                                                                                                                                                      
Out[2]: YAML([['1', '2', '3'], ['f', '5', '6']])

crdoconnor avatar Sep 21 '19 14:09 crdoconnor

Leaving this open for now as I should probably add an example of this to the docs.

crdoconnor avatar Sep 21 '19 15:09 crdoconnor

Yes, works perfectly fine. Sorry. I forgot to let you know.

fkromer avatar Sep 21 '19 20:09 fkromer

It works for me. test file:

seq_of_seqs:
  -
    - "a"
    - "b"
  -
    - 1
    - 2

output of strictyaml.load(test).data sent to pprint

{'seq_of_seqs': [['a', 'b'], ['1', '2']]}

julie777 avatar Mar 05 '22 00:03 julie777