devnote-dev / devnote-dev/xmlt

how to nest multiple classes and deserialize those from xml

Đang mở
#2 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug good first issue
Ngôn ngữ chính
Crystal
Star
8
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

how to make the following work

```crystal
require "xmlt"

XML_FRAGMET = <<-XML

2

test


test2

XML

class Element
include XMLT::Serializable

property name : String
end

class Repository
include XMLT::Serializable

property version : String

@[XMLT::Field(new_root: "element")]
property elements : Array(Element)
end

module Txmltest
repo = Repository.from_xml XML_FRAGMET, root: "repository"
p! repo.version
if elements = repo.elements
elements.each do |elm|
p! elm
end
end
end
```

I get the following error

```
~/P/C/txmltest (main) [1]> shards run
Dependencies are satisfied
Building: txmltest
Error target txmltest failed to compile:
Showing last frame. Use --error-trace for full trace.

In lib/xmlt/src/objects.cr:18:5

18 | new node, root: root
^--
Error: no overload matches 'Array(Element).new' with types XML::Node, root: String

Overloads are:
- Array(T).new(size : Int, value : T)
- Array(T).new(initial_capacity : Int)
- Array(T).new()
- Array(T).new(size : Int, & : (Int32 -> T))
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.