|
We have an API endpoint that returns a type that looks like: { public string Foo; public int Bar; public Dictionary<string,string> FooMetadata; } and it serializes and deserializes just fine with System.Text.Json. Looking at our swagger docs there is actually a valid JSON schema thing that forces an object into being a flat set of key -> value pairings: { "type": "object", "additionalProperties": { "type": "string" } } In practice it allows clients to "tag" objects with metadata that they care about but doesn't fit anywhere in our schema. I guess if you had no access to any docs or schema definitions and pulled an object like: {"Foo":"butt", "Bar":0, "FooMetadata": {"Yos":"pos"}} from the API, there's nothing in the JSON that is explicitly saying that 'FooMetadata' is a Map that can contain arbitrary keys as opposed to a statically typed object that looks like { public string Yos; }. Having an array of objects with "Key" and "Value" fields serves as a hint that those keys shouldn't be baked into a type definition, but then allows for duplicate keys. It looks like there is a way to force uniqueness of array elements in JSON schema but at that point I would probably go the XSD route because this poo poo is awful. Definitely not a huge fan of "everything is a map" typing which gets you this kind of javascript hotness: var foo = [0,1,2]; foo["yos"] = "pos";
|
# ? Jul 28, 2020 13:44 |
|
|
# ? Apr 23, 2024 22:01 |
|
redleader posted:xml (the superior data exchange format) redleader posted:* maybe you can do something in an xsd to ensure a key only appears once idk yeah you can lotta people are scared of xsds though
|
# ? Jul 28, 2020 14:11 |
|
DELETE CASCADE posted:what is the point of json
|
# ? Jul 28, 2020 15:10 |
|
human readable data interchange format for javascript op the intent and the usage, as always, might diverge
|
# ? Jul 28, 2020 15:36 |
|
Why did they use JSON is a good question, why did they use HTTP is just as good. Unless your target is a web browser and only their ergonomics matter, start your API with something like TCP and MsgPack or ProtoBuf and then add an HTTP JSON adapter on top for those plebs.
|
# ? Jul 28, 2020 15:39 |
|
xtal posted:Why did they use JSON is a good question, why did they use HTTP is just as good. Unless your target is a web browser and only their ergonomics matter, start your API with something like TCP and MsgPack or ProtoBuf and then add an HTTP JSON adapter on top for those plebs. why not just use the (my language serialization) built in serialization, everyone should know how it works by now, it's obvious and simple, as opposed to json
|
# ? Jul 28, 2020 15:46 |
|
i love msgpack
|
# ? Jul 28, 2020 15:46 |
|
xtal posted:Why did they use JSON is a good question, why did they use HTTP is just as good. Unless your target is a web browser and only their ergonomics matter, start your API with something like TCP and MsgPack or ProtoBuf and then add an HTTP JSON adapter on top for those plebs. What's the advantage of doing TCP and MsgPack over something like gRPC so that you don't have to implement your own streaming, sessions, metadata, all that stuff?
|
# ? Jul 28, 2020 15:47 |
|
Twerk from Home posted:What's the advantage of doing TCP and MsgPack over something like gRPC so that you don't have to implement your own streaming, sessions, metadata, all that stuff? gRPC is pretty good actually, HTTP/2 fixes most of the issues you'd get with an HTTP API, but most of the time it still doesn't use other HTTP features like caching. So my gripe is with making extensions to a document serving protocol to make it work for other use cases, when it was unnecessary in those use cases to begin with.
|
# ? Jul 28, 2020 15:55 |
|
redleader posted:xml (the superior data exchange format) doesn't really have any good way of serialising dictionaries. there are a few ways to xmlise a dict, but they all run into the same problem as that key-value list*. it's kind of amusing because they're using json, which does have good syntax for dictionaries, but they managed to gently caress it up anyway Maybe the JSON API is directly derived from the XML API.
|
# ? Jul 28, 2020 20:54 |
|
JSON from {friday : 13}
|
# ? Jul 29, 2020 01:48 |
|
echinopsis posted:JSON from {"friday" : 13} ftfy
|
# ? Jul 29, 2020 01:55 |
|
i think flatbuffers are ok its a pain to work with if you want to frequently make piecemeal edits to existing ones but it's very fast if you don't need to do that very often
|
# ? Jul 29, 2020 02:02 |
|
serialization is a direct result of computers being able to communicate which, as we all know, is the work of the devil and has led to nothing but misery for the human race
|
# ? Jul 29, 2020 02:43 |
|
adama was right
|
# ? Jul 29, 2020 02:47 |
|
redleader posted:serialization is a direct result of computers being able to communicate which, as we all know, is the work of the devil and has led to nothing but misery for the human race When you think about it everything is serialized as 1s and 0s, so you're actually even more correct about it being terrible
|
# ? Jul 29, 2020 03:07 |
|
xtal posted:When you think about it everything is serialized as 1s and 0s, so you're actually even more correct about it being terrible and then it's serialized to weird little random voltages stuck in silicon or oddly magnetized areas of ferric ceramic or polymer or whatever. awful
|
# ? Jul 29, 2020 03:35 |
|
Doom Mathematic posted:Maybe the JSON API is directly derived from the XML API. if we're taking about the example from the aws sdk in the op, it's this
|
# ? Jul 29, 2020 04:06 |
|
honestly I wouldn’t care so much how aws represents things on the wire if their “high level” python sdk converted it to a more consumer-friendly form
|
# ? Jul 29, 2020 08:08 |
|
xtal posted:When you think about it everything is serialized as 1s and 0s, so you're actually even more correct about it being terrible
|
# ? Jul 29, 2020 12:54 |
|
Soricidus posted:honestly I wouldn’t care so much how aws represents things on the wire if their “high level” python sdk converted it to a more consumer-friendly form botocore uses auto-generated models so do all their other sdks except java iirc
|
# ? Jul 29, 2020 12:57 |
|
the thing I'm working on right now does serialisation by generating instructions for a custom VM running on the server which then reproduce the encoded data when executed this is used as a universal communication protocol for a dozen different server applications, each with their own special instruction sets some of the encoded data also includes a lex/yacc custom language for filtering (because regexes are too pedestrian I guess), which is then transpiled into said instructions none of this is the actually terrible part, that's where the instructions are added and removed to the data package in event callbacks from the GUI, which now I have to remove someone really worked hard on that job retention then again he doesn't work there anymore so who got the last laugh huh? well certainly not me Private Speech fucked around with this message at 18:06 on Jul 29, 2020 |
# ? Jul 29, 2020 16:33 |
|
there is also no documentation on those instruction sets outside of looking at the server source code, which has about one comment per thousand lines of code though each server does have an enum listing its instructions (where position in said enum = instruction code), naturally this is not in any consistent file, but rather a random header with a quality name like tlssyn.h (actual name) Private Speech fucked around with this message at 17:29 on Jul 29, 2020 |
# ? Jul 29, 2020 16:44 |
|
each server instruction set has over 200 instructions, some with very clear names like HALF_OR (this is apparently a conditional jmp/goto instruction to break condition evaluation early, as in: "if (true || whatever)") that is not to be confused with INT_OR and BYTE_OR, which do boolean arithmetic I believe this qualifies for the thread on enough levels to warrant a multipost e: albeit a lot of it can be excused by the code being going on 30 years old anyway webdev is terrible and systems programming is so much better let me tell you, json more like failson, furthermore Private Speech fucked around with this message at 18:07 on Jul 29, 2020 |
# ? Jul 29, 2020 16:49 |
|
Blinkz0rz posted:botocore uses auto-generated models I know. but that’s an implementation detail and they are leaking the poo poo out of it. it’s loving amazon, they have plenty of resources to maintain some qol tweaks for really common and basic things like tag dictionaries. but yeah it’s amazon so why am I even surprised they hold good design and user experience in open contempt
|
# ? Jul 29, 2020 18:47 |
|
as a primarily-frontend dev i get kinda confused by all the serialization talk just b/c it seems like browser json is still faster in any benchmark i've been messin around with multiplayer websocket games lately so i'm theoretically in the market for fast (de)serialization and smaller message sizes but as far as i can tell from googling, json is still the way to go. signalr supports messagepack but provides zero actual benchmark tools indicating anything about performance, which you'd really kinda hope for if they've bothered to add the option
|
# ? Jul 29, 2020 18:58 |
|
MsgPack is a little better in a browser due to faster transit times, going protobufs or similar are all a fair bit slower still. I did see a benchmark list something else faster, but probably bogus testing per typical for webdev. MsgPack has been super guilty on that front too. I basically wrote frontend and backend to support both, then testing how each ran. MsgPack faired better. I only bothered because a JSON C++ library supported it relatively transparently. MrMoo fucked around with this message at 19:16 on Jul 29, 2020 |
# ? Jul 29, 2020 19:08 |
|
I guess it’s like js as a whole. if everyone does things badly enough, companies have to pour resources into mitigating that, whereas the things that were not terrible to begin with don’t see anything like the same kind of effort.
|
# ? Jul 29, 2020 21:23 |
|
Blinkz0rz posted:botocore uses auto-generated models the java SDK uses autogenerated models as well. you can even get the generator source code and run it yourself. https://github.com/aws/aws-sdk-java-v2/tree/master/codegen here's the maven plugin code: https://github.com/aws/aws-sdk-java-v2/tree/master/codegen-maven-plugin
|
# ? Jul 30, 2020 17:44 |
|
ok so I've only just started fuckng around in javascript and I came across this situation that really fuckin baffled me and only now do I know why I was multiplying a variable by 1.1 and the program was running as expected I changed the number to 2, and it would halt and talk about an undefined object and it really stumped me for a while, and so I put a ; after the 2, and it executed... ok.. so I removed the ; and yep it fails to execute again. changed back to 1.1 and it worked regardless of the semicolon fuckin stupid
|
# ? Jul 31, 2020 12:14 |
|
code:
|
# ? Jul 31, 2020 12:16 |
|
it’s tolerated because semicolons are boring
|
# ? Jul 31, 2020 13:19 |
|
ah another member to the ‘javascript is a steaming pile of garbage’ club. i’ll update the massive tome
|
# ? Jul 31, 2020 13:21 |
|
get used to putting a semicolon at the end of each statement, it’s good practice for if you migrate to an actually useable language
|
# ? Jul 31, 2020 13:26 |
|
jesus WEP posted:get used to putting a semicolon at the end of each statement, it’s good practice for if you migrate to an actually useable language that's not what the problem in the last post is though - he doesn't want to end the statement there, but js puts an implicit comma there anyway
|
# ? Jul 31, 2020 13:29 |
|
javascript is.... bad?!
|
# ? Jul 31, 2020 13:29 |
|
sometimes whitespace matters?????
|
# ? Jul 31, 2020 13:30 |
|
Private Speech posted:that's not what the problem in the last post is though - he doesn't want to end the statement there, but js puts an implicit comma there anyway
|
# ? Jul 31, 2020 13:31 |
|
Blinkz0rz posted:sometimes whitespace matters????? don't be daft
|
# ? Jul 31, 2020 13:50 |
|
|
# ? Apr 23, 2024 22:01 |
|
how do people feel about #pragma once? there's this GCC dev laying out a decent case for why it's bad on a personal level I don't use it for more complex projects, and both cppcoreguidelines and Google C++ guidelines don't recommend it either, with broadly the same reasoning stackoverflow and reddit have a lot of people agitating hard for it though
|
# ? Jul 31, 2020 14:52 |