我最近才开始查看 pydantic 的文档,但我没有看到从 dict 对象生成模型的直接方法。有没有办法生成一个,然后我可以检索并保存以备后用?
这是我拥有的数据示例。
{
'id': '424c015f-7170-4ac5-8f59-096b83fe5f5806082020',
'contacts': [{
'displayName': 'Norma Fisher',
'id': '544aa395-0e63-4f9a-8cd4-767b3040146d'
}],
'startTime': '2020-06-08T09:38:00+00:00'
}
Run Code Online (Sandbox Code Playgroud)
期待一个类似于......的模型
class NewModel(BaseModel):
id: str
contacts: list
startTime: str
Run Code Online (Sandbox Code Playgroud) 我正在尝试利用 Typescript 项目引用在 monorepo 中构建 Vue 应用程序。我当前的项目结构如下:
client/
package.json
tsconfig.json
src/
...
server/
package.json
tsconfig.json
src/
...
shared/
package.json
tsconfig.json
preferences.ts
permissions.ts
interfaces/
...
Run Code Online (Sandbox Code Playgroud)
client/tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"strictNullChecks": false,
"strictPropertyInitialization": false,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noImplicitAny": false,
"baseUrl": ".",
"types": ["mocha", "chai", "vuetify", "webpack-env"],
"paths": {
"@/*": ["src/*"],
"@shared/*": ["../shared/*"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx", …Run Code Online (Sandbox Code Playgroud)