Skip to main content
28 votes
Accepted

How do you fix the wrong-case-sensitivity dictionary setting bug-pattern?

Well, do you see the problem with this? Because we put a public setter on there. So don't have a public setter. Create a new class CaseInsensitiveDictionary that contains a private Dictionary ...
mmathis's user avatar
  • 5,586
23 votes
Accepted

Is it a bad idea to pass JSON objects on the query string for an API "search" operation?

Its not a brilliant idea. The URI is not really a good place for data of unpredictable length, and although there is no 'official' maximum length, many webservers apply their own limit (IIS is 2083 ...
richzilla's user avatar
  • 1,153
15 votes

JSON without quotes for keys

It sounds like you are looking for a data-serialization format that is human-readable and version-control-friendly but not as strict about quotes as JSON. Such formats include: Relaxed JSON (RJSON) (...
David Cary's user avatar
  • 1,492
14 votes

JSON without quotes for keys

Keys in a JSON dictionary are not quoted strings, they are strings. Strings in JSON start with a quote, continue with escaped or unescaped characters, and end with a string. You can’t have different ...
gnasher729's user avatar
  • 49.4k
14 votes
Accepted

What is the normal form of JSON? What is theory that you can't automate normalizing?

In short JSON is a data representation according to a schema-less syntax without predefined semantics. On the opposite, normal forms are defined for abstract data model with a relational semantic ...
Christophe's user avatar
  • 82.3k
13 votes

Is it a good practice to have a special value "ALL" in an enum

Depends on whether your available eras are available to the calling application. Presumably they are so the user can select what they're interested in. If that's the case then it's a front-end issue ...
LoztInSpace's user avatar
  • 1,348
12 votes

How to represent a set in JSON?

Don't try to represent sets in JSON. Do it when parsing the data instead. Your JSON data should have a schema which specifies which fields should be treated as a set, or you may have a metadata ...
Lie Ryan's user avatar
  • 12.5k
12 votes

How should an API handle unsupported fields?

Whether the API rejects or ignores unsupported fields is a concern for the documentation used by consumers. Pick one, and then document this behavior so clients know what to expect. Let them decide ...
Greg Burghardt's user avatar
11 votes
Accepted

Why protobuf is said to be in binary format although we write it in text format similar to json

This would be more clear if you were comparing two more similar pieces of data with non-text data components. For example, the following JSON is ALL text: { "NumberOfClients": 20 } The 20 is two ...
TheCatWhisperer's user avatar
11 votes

Is there a canonical way to handle JSON data format changes?

Problems Generally speaking, handling different versions of the same data model in the same code results in extra unwanted complexity. Some common issues include: Fields renamed Data types changed ...
Ben Cottrell's user avatar
  • 12.1k
11 votes

How do you fix the wrong-case-sensitivity dictionary setting bug-pattern?

mmathis's answer gives you the practical solution to the problem, but I'll look at this from a more theoretical point of view. What you're looking at here is a very close corollary of the Liskov ...
Philip Kendall's user avatar
10 votes
Accepted

Keeping a JSON copy of a database

Basic Drawbacks Excess complexity, redundancy. More potential for bugs (more paths through more code), more time to develop, test, and more cost to maintain, forever. Stale Data The moment the ...
joshp's user avatar
  • 3,511
9 votes

REST API - Should API Return Nested JSON Objects?

I second the approach presented here https://www.slideshare.net/stormpath/rest-jsonapis In short, include the nested resource as links in the parent resource, meanwhile, provide an expand parameter ...
Wei Qiu's user avatar
  • 191
9 votes
Accepted

Should REST API return escaped user generated content

It belongs to the API to correctly serialize JSON: the user is not expected to be able to break JSON schema by introducing characters considered special in JSON, such as the quote character. It doesn'...
Arseni Mourzenko's user avatar
9 votes
Accepted

Should error codes in JSON be integers or strings?

I would go with text. It's OK to have a string where you only use numbers. As a rule of thumb: you should not use integers for things that are not mathematical in nature. That is, if you can do ...
JimmyJames's user avatar
  • 31.1k
9 votes
Accepted

How do you pass enums between microservices, without need to have copies of enums in different services?

Yes and No, You should have a client and model library published as part of the API project. Consumers of the api can use this library. So they will be deserialising to the same dtos or entities that ...
Ewan's user avatar
  • 84.6k
9 votes

How do you fix the wrong-case-sensitivity dictionary setting bug-pattern?

A option I used in the past, as an alternative to an CaseInsensitiveDictionary was a CaseInsensitiveString type. public readonly struct CaseInsensitiveString : IEquatable<CaseInsensitiveString&...
Martin Gleich's user avatar
8 votes

How deeply can a JSON object be nested?

Many JSON parsers and formatters use recursion (i.e., ArduinoJSON and the IBM DastaPower Gateway). This means that deeply nested JSON objects can be used to attack implementations that use this ...
Myst's user avatar
  • 181
8 votes

How should an API handle unsupported fields?

This comment is very relevant. It is only an internal API. The argument of the consumers is that they will ask me to support the age field ans want to start changing their app and send that field ...
Helena's user avatar
  • 827
7 votes

Inserting JSON document with `.` in key to MongoDB

There are a few alternatives: 1. Replace dots by a dash. This would be my favorite approach, as it keeps the structure explicit enough. Since according to you, “it is pretty much a one time ...
Arseni Mourzenko's user avatar
6 votes

Is it a good practice to have a special value "ALL" in an enum

If no eras provided in the input, then this book is considered to cover all eras. This, and also having a special 'ALL' case, are bad IMHO - your APIs should be explicit where possible. Having special ...
GoatInTheMachine's user avatar
6 votes

Web API Response, Error Code Convention

How can you know which field caused this error? Make it explicit? 401 # The HTTP "Unauthorized" code is outside the JSON. { "message": "Your credentials cannot be accepted", "invalid_fields": [ ...
9000's user avatar
  • 24.4k
6 votes
Accepted

When does a JSON object become a burden on memory?

There is no general rule, but here's a suggestion. Retrieve everything in one request unless the retrieval and loading takes too long. If it's awkward to retrieve in one request and you would save ...
joshp's user avatar
  • 3,511
6 votes
Accepted

How to create useful error messages in a JSON REST API without leaking implementation details across layers?

You are probably trying to generate the JSON error information at the wrong level in your architecture. If you convert data from one format to another at a layer boundary (like going from PersonInput ...
Bart van Ingen Schenau's user avatar
6 votes

Why not program our video text terminals/terminal emulators to use something JSON or XML on the backend instead of ANSI escape sequences?

Your question is sort of like saying assembly is difficult to work with, so computers should use higher level languages instead. The ANSI format is the right level of abstraction for working with ...
Karl Bielefeldt's user avatar
6 votes

Should error codes in JSON be integers or strings?

I'd suggest to a static constant string to both be able to map to i18n and keep expressiveness. Something like this is nice: { error: 'invalid_id' } And you can even scope it to module to locate ...
Diego d'Ursel's user avatar
6 votes
Accepted

Constantly writing a JSON file

The last time I had a requirement like that, the process looked like When starting a new file, write the characters [\n to it to open a JSON array. When appending to an existing file, seek to the end....
Bart van Ingen Schenau's user avatar
6 votes

How should an API handle unsupported fields?

REST APIs publish contracts so that consumers may know how to use them. A contract is a written agreement between the publisher and consumer. Extraneous fields can be handled however you like, ...
Dan Wilson's user avatar
  • 3,163
6 votes

How should an API handle unsupported fields?

The Robustness principle, also called "Postel's law" states: be conservative in what you do, be liberal in what you accept from others For your case it means to accept the unknown fields ...
EricSchaefer's user avatar
  • 2,111
5 votes

JSON Web Token - why is the payload public?

The use of the term signature in the RFC is analogous to a digital signature in asymmetric cryptography. In asymmetric cryptography if the sender encrypts a message with their private key, anyone who ...
Micah B.'s user avatar
  • 156

Only top scored, non community-wiki answers of a minimum length are eligible