File size: 696 Bytes
cc93546
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from pydantic import BaseModel
from typing import List, Optional

class ForumUser(BaseModel):
    id: int
    anonymous_id: str
    display_name: str
    avatar_image_url: str
    html_url: str
    pronouns: Optional[str]

class ForumPost(BaseModel):
    id: int
    user_id: int
    parent_id: Optional[int]
    created_at: str
    updated_at: str
    rating_count: Optional[int]
    rating_sum: Optional[int]
    user_name: str
    message: str
    user: ForumUser
    read_state: str
    forced_read_state: bool

def get_data_from_json(file_path):
    with open(file_path, "r") as f:
        json_data = json.load(f)
        data = [ForumPost(**item) for item in json_data]
        return data