Hyston blog
About ā€¢ RSS

Json to classes

2020-10-22 22:19

Just a little thing, that I learned today. Here is the usual example: someone gave you example json for some API, that you need to implement and first step would be ā€“ created to classes for this json. There is a nice feature in Visual Studio: copy json in clipboard, then you can Edit -> Paste Special-> Paste JSON as classes.
vs paste json as class
One problem for me was that all fields were lowercase. Fixing them manually was too boring, so I wrote regex to replace first letter to uppercase: (\bint|\bbool|\bstring|\bfloat\bDateTime) ([a-z]) <- replace this
$1 \u$2 <- to this
vscode replace regex
No sure, that it will be useful for someone, Iā€™m just proud of myself each time when I can use regex šŸ¤“

Next entry → ← Prev entry