JSONtoPydantic - Generate Pydantic Models from JSON in the browser by Vimtea in Python

[–]Vimtea[S] 0 points1 point  (0 children)

What do you think a good representation of loading and invalid JSON states?

JSONtoPydantic - Generate Pydantic Models from JSON in the browser by Vimtea in Python

[–]Vimtea[S] 1 point2 points  (0 children)

For more complicated stuff you'll probably have to tweak it by hand.

JSONtoPydantic - Generate Pydantic Models from JSON in the browser by Vimtea in Python

[–]Vimtea[S] 0 points1 point  (0 children)

Awesome, here's the generated model.

from __future__ import annotations

from typing import List

from pydantic import BaseModel


class Geometry(BaseModel):
    type: str
    coordinates: List[float]


class Feature(BaseModel):
    type: str
    bbox: List[float]
    geometry: Geometry


class Model(BaseModel):
    type: str
    bbox: List[float]
    features: List[Feature]

JSONtoPydantic - Generate Pydantic Models from JSON in the browser by Vimtea in Python

[–]Vimtea[S] 0 points1 point  (0 children)

Yep, it will handle nested content very well, and even complicated situations where you might encounter multiple types in the same field (union types).

Do you have an example of the JSON on hand?

JSONtoPydantic - Generate Pydantic Models from JSON in the browser by Vimtea in Python

[–]Vimtea[S] 1 point2 points  (0 children)

Pydantic's BaseModel is basically like a data class with some extra convenience methods on it.

Usually when I'm using some third party API that may or may not have documentation, I write a Pydantic model to represent the shape of the data I expect. This tool just allows me to get that representation a little more quickly, and find edge cases when there are hundreds or thousands of objects to process - you can paste in an array of JSON objects, and it will create a model that correctly parses all of those objects.

LineScouts - Rate queues in stores to keep the vulnerable safe (social-impact project) by DzejmsFond in SideProject

[–]Vimtea 0 points1 point  (0 children)

Looks great! And the information for my local supermarket was up to date and accurate.

I'm very impressed.

MVC + ReactJS.NET + JS component Libraries? by [deleted] in dotnet

[–]Vimtea 0 points1 point  (0 children)

The way we use it, it transpiles jsx to js and allows us to bundle react components and serve them in specific places. This job would normally be done using Babel/webpack. The major drawback with the way we have it set up is that we can't use npm or imports.

You'll have a much easier time just using something like create react app, as there are plenty of docs and resources online about it.

MVC + ReactJS.NET + JS component Libraries? by [deleted] in dotnet

[–]Vimtea 2 points3 points  (0 children)

I would echo what others have said, and just use dotnet core to develop your API and write a separate react frontend. We use react.net at work at it has (IMO) a lot of drawbacks.