Skip to content

Commit

Permalink
Update README.md to include a note for OnlyList
Browse files Browse the repository at this point in the history
  • Loading branch information
dhvcc committed Oct 3, 2023
1 parent 99cb961 commit 610a269
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,40 @@ Turns into
}
```

Multiple children of a tag will be put into a list

```xml
<div>
<tag>content</tag>
<tag>content2</tag>
</div>
```

Results in a list

```python
[
{ "tag": "content" },
{ "tag": "content" },
]
```

If you don't want to deal with those conditions and parse something **always** as a list -
please, use `rss_parser.models.types.only_list.OnlyList` like we did in `Channel`
```python
from typing import Optional
from pydantic import Field
from rss_parser.models.item import Item
from rss_parser.models.types.only_list import OnlyList
from rss_parser.models.types.tag import Tag

...

class OptionalChannelElementsMixin(...):
...
items: Optional[OnlyList[Tag[Item]]] = Field(alias="item", default=[])
```

### Tag field

This is a generic field that handles tags as raw data or a dictonary returned with attributes
Expand Down

0 comments on commit 610a269

Please sign in to comment.