Storing objects in key/value stores - serialized or separate values?
It really depends. You've identified one of the primary flaws with a key->value design (structure).

Your former example is more like a document-oriented database, which is kind of an extra implementation on top of a key->value store. Using something like JSON for your document is one approach. Some document-oriented DB's will optimize/index that for you.

Your latter example is more of a traditional key->value approach.



To answer your question more specifically, one problem with storing a JSON string/object as your value would be that every time you want to access part of that value, you generally have to parse (and possibly decompress) the whole thing. The problem with the key->value design is a lack of structure, everything is almost flat. How are you going to represent a class/object this way, and what if you have a web of complicated classes/objects, etc.?

https://en.wikipedia.org/wiki/NoSQL#Types_and_examples