Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
nam178875796yI think not the reader's fault, probably the writer somehow produce byte array as [1,2, 3 ,..] etc,
and if the reader says he wants a byte[], the json library would expect something like a base64 string instead -
@Pickman
Don't ask. I only know the lady who wrote the code was fired partly due to my recommendation -
devTea240886y@Pickman actually I have a problem reading js byte array, what the equivalent of both int8 and uint8 on c#? Since there’s no int8 on c#. Normally I sent a base64
-
I’m confused as why you are processing json like xml. I just turn it into a class and deal with the object returned by JsonConvert.DeseralizeObject<T>(json)
-
@Pickman public properties of classes in C# are capitalized by convention. Ah, but after writing this initially, I see the to line. So, not typical to have a local variable capitalized.
-
@Root
Line 1528: No space after Token in string.
Line 1529: How the hell is it even evaluated?
Line 1536: Space before colon but not after it
Line 1536: Unnecessary typecast to byte
Do I need to go on?
Oh last but not least, this was copy/pasted 15 times in the file. I guess back then you couldn't write a function in C# LoL -
Pickman6566y@devTea as said before I know essentially nothing of C# but I guess that byte and sbyte are supposed to be the equivalent types. Of course if it's for a real project I would check the manual to make sure of the proper implementation of the encoding (it looks straightforward, but you never know...).
-
@devTea No int8 in C#? If with int8 you mean 8 bit signed integer, well, there's an equivalent in C#. It's called sbyte, or byte if you want it unsigned.
-
I'd say you can use JsonConvert.DeserializeObject<byte[]>(Token.ToString()) or even Token.Value<byte[]>()
-
devTea240886y@CodeMasterAlex it throws error when I try to pass to the webapi, I also pass as one of json object
-
@devTea Too bad I don't know your actual code etc. I use it a lot in web api and works well. Probably it's one of those small overlooked things...
-
devTea240886y@CodeMasterAlex thanks for your tip anyway, I’ll try it when I have to refactored my code later
Related Rants
Came across this in a part of a web service I inherited from a junior we fired last year.
I am no C# expert, but I do believe there are better ways to read a byte array from a JSON string, am I right?
rant