[https://nim-lang.org/docs/marshal.html](https://nim-lang.org/docs/marshal.html)

I just started playing with marshal module. Seems to be the easiest way to 
store objects in an human readable form to disk. My test is
    
    
    import
      marshal, streams
    
    var s = newFileStream("somefile.txt", fmWrite)
    
    type
      R = object
        x, y, w, h: int
      
      O = object
        name: string
        r: seq[R]
    
    var o: O
    o.name = "test"
    
    o.r.add(R(x: 1, y: 2, w: 2, h: 6))
    o.r.add(R(x: 5, y: 7, w: 20, h: 8))
    o.r.add(R(x: 9, y: 17, w: 28, h: 18))
    
    store(s, o)
    s.close()
    
    
    Run

Result is
    
    
    $ cat somefile.txt
    {"name": "test", "r": [{"x": 1, "y": 2, "w": 2, "h": 6}, {"x": 5, "y": 7, 
"w": 20, "h": 8}, {"x": 9, "y": 17, "w": 28, "h": 18}]}
    
    
    Run

So all is dumped to one single very long line? Then that is not really human 
readable. The other disadvantage of marshal is that it seems to work not with 
inheritance, it can only use compile time types, but that should be OK for my 
use case, as I try to avoid inheritance.

So I may have to use JSON or extern YAML module? I really like YAML, as it has 
good human readability and can be even edited with a text editor. And if I 
remember correctly its author was a bright one. But I think he has retired 
years ago, can not even remember his name.

So my question would be: What is the future of YAML module, will it at least 
still work with Nim 2.0 ?

Reply via email to