Some more research turned up a macro in jsffi that works the way I want. Here's 
the improved code.
    
    
    import jsffi
    
    type
      Person = ref object of JsObject
        name: cstring
        val: int
        lang: cstring
      
      Rec = ref object of JsObject
        name: cstring
        val: int
    
    let obj1 {.exportc: "obj1".} = Rec{
      friends: [
        Person{
          val: 19,
          name: "wendy",
          lang: "nim"
        }
      ],
      name: "sam",
      val: 21
    }
    
    var myobj1 {.exportc: "myobj1".} = obj1
    
    
    Run

Reply via email to