Anarchist
Anarchist
CC#
Created by Anarchist on 2/7/2024 in #help
Deserialise part of a json response
Hello, how could I use newtonsoft to deserialise part of a large json response into a smaller set of objects? e.g. if the response is...
{
"count": 100,
"next": "https://api",
"previous": null,
"results": [
{
"name": "a",
"id": 1,
"extra": "whatever"
},
{
"name": "b",
"id": 2,
"extra": "whatever"
},
]
}
{
"count": 100,
"next": "https://api",
"previous": null,
"results": [
{
"name": "a",
"id": 1,
"extra": "whatever"
},
{
"name": "b",
"id": 2,
"extra": "whatever"
},
]
}
...how would I extract just an array of the elements in result, with only some params, e.g. [ { "a", 1 }, { "b" , 2 } ]
12 replies
CC#
Created by Anarchist on 12/12/2022 in #help
❔ Are TryAsync methods acceptable?
I've just been refactoring some implementations of a method I have to go from T Load() to bool TryLoad(out T? result), which as far as I'm concerned is not an anti pattern. I was about to do the same for my Task<T> LoadAsync methods but am wondering if this is bad practice and having bool TryLoadAsync(out Task<T?> result) may have some unforeseen consequences?
10 replies