|
|
The second. As you say it's maintainable, plus more easily extensible, and I like having an actual name by which to refer to the data (just seems easier when debugging in DevTools)
cheers
Chris Maunder
|
|
|
|
|
I swear I read that subject line as "JSOP responses".
I thought I was about to read something with a title such as "The Complete Works of JSOP: All the Sage Wisdom and Life Advice You'll Ever Need as a Collection of One Liners".
|
|
|
|
|
do you prefer C# method to return
List<T> GetSomeData<T>()
or
T GetSomeData<T>()
if one or the other, why?
Personally I don't care either way.
Same for JSON.
|
|
|
|
|
I prefer the latter. As you point out, it's future-proofed for additions.
Also, it can be easily deserialized into a C# object using something like Newtonsoft. That's where I'm generally consuming these data.
That might be an important consideration; just because nobody's planning to deserialize into C# (or whatever) today, it means no refactoring when they do.
|
|
|
|
|
Personally, I prefer to always have the response wrapped.
First, it makes it easier to extend in the future without breaking things.
I have been around long enough, that code I wrote in the 1980s is still being used today!
And the hardest thing to adjust is the data structure changes, because it impacts everything!
Next, it just seems more consistent to always be wrapped. I could be biased by using a system or two that were always wrapped. And their inner objects were always consistent objects, and moveable between other container objects.
|
|
|
|
|
Anything that is self-documenting is a good thing, IMO (#2).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
So your preferred answer to GET payment methods is a single object?
Academically, I'd say the direct json array is the correct format.
Here's an example endpoint and response from GitHub to retrieve followers.
However, people have been doing practical choices over academic ones since the dawn of time. If your in control of both the api and the client, knock yourself out, as long as you're consistent.
|
|
|
|
|
Here is my 2 cents of crazy.
In JS I have an Array. let my_array = ["hi"];
It is going well. push, pop, shift, filter, map...
Now I want to add some number counter say Groups, to save searching how many distinct groups are in the Array?
my_array._groups = 44;
So that works.
I can check the number of groups.
Now I need to store my my_array. JSON?
Well, JSON.stringify(my_array), only captures the array and does not include _groups.
Using an object my_array = {array=["hi"]};
we store _groups =44.
Now JSON.strinigy contains _groups.
but calls to array require either putting through a wrapper object to pass through functions, or adding .array between the functions.
Conclusion: I am not sure what my brain is thinking today. Maybe the second wrapper has benefits as you said.
|
|
|
|
|
|
Has anyone downloaded VS2019 yet?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Not interested. Mickeysoft, Office and VS together are giving me a really nice day already.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I've only just started moving to VS2017 ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Same here
Went on to 17 on Monday
Rules for the FOSW ![ ^]
if(!string.IsNullOrWhiteSpace(_signature))
{
MessageBox.Show("This is my signature: " + Environment.NewLine + _signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
April Fools Day? I see ...
I started a few weeks ago, but haven't moved a project proper yet.
Still got VS13, 15, and 17 installed - I'm surprised I never refitted 08 and 10!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Well, i thought VS Studio 17 to be a joke so it was obvious to switch on April 1.
But so far everything necessary is transferred and working !
Rules for the FOSW ![ ^]
if(!string.IsNullOrWhiteSpace(_signature))
{
MessageBox.Show("This is my signature: " + Environment.NewLine + _signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
Not downloaded an MS-IDE ever since it required me to sign in with a email that's connected to a password passport.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
modified 3-Apr-19 8:21am.
|
|
|
|
|
Bravo!
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
It is not something that is beneficial nor required for development; I do not log in to calc.exe, I do not see why an IDE should be any different.
Also bricked my phone again, so am without one for the time. Means I could not create an account even if I wanted to. Why do I need to own a phone to launch a desktop application?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Or, generally, why must I marry Mickeysoft if I want to buy something from them?
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
???
Haven't had to do that.
Sign in with my microsoft account yeah but nowhere did I have to provide my passport.
Tom
|
|
|
|
|
Tom Deketelaere wrote: Sign in with my microsoft account yeah but nowhere did I have to provide my passport. Not that passport, but the service called "MS Passport". Your emailadress must be registered there.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Ah that kind off "passport", didn't even know about that service (or I did and forgot).
I was thinking the physical passport thing
It's possible my email is linked to it, don't remember doing that but ...
Tom
|
|
|
|
|
When I was required to do that with VS2017, I just made up a dummy email and password. That pacified the installer so all's good.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
No login-screen when you launch the IDE, as 2012 does?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|