Adding JsonShapeDeserializer - #3889
Conversation
…porting TimestampFormatTrait
|
|
||
| size_t BeginStruct() { | ||
| auto tok = NextToken(); | ||
| if (tok != Token::ObjectStart) { |
There was a problem hiding this comment.
if the token is not object start, we return 0, if it is we also return 0. what is the meaning of the return type 0 as a size_t? shouldnt it be returning whether o not it could begin a struct? i think this is so perpandicular because java has a readStruct
which in c++ would look something like
template<typename T>
class StructMemberConsumer {
public:
virtual ~StructMemberConsumer() = default;
virutal void accept(const T& state, const Schema& memberSchema, ShapeDeserializer memberDeserializer) = 0;
virutal void unknownMember(T state, String memberName) {}
}
template<typename T>
void readStruct(const Schema& schema,
T& state,
StructMemberConsumer<T> structMemberConsumer)
{
...
}so my question here, is why are we doing begin and end in deserilize? there is no way to "begin" or "end" in this context. because we are writing to a object not a symbol to a buffer.
i'd push back here and try to match java on this, we should be deserializing into a object not arbitrarily.
| s.EndStructure(); | ||
| auto json = s.GetPayload().GetResult(); | ||
|
|
||
| JsonShapeDeserializer d(json.c_str(), json.size()); |
There was a problem hiding this comment.
lets re-contextualize this test, and maybe all the tests we're writing, we want to be serializing and de-serializing to a type T. so imagine the class
class serializable {
public
serializable(deserializer*, std::string) {
... construct from string using the deserialized
}
std::string serialize(serializer*) {
... write to a string
}
}
we want to keep the idea in mind that we are serializing to a class, and to a string from one. the way it is currently factored we dont know what we are deserializing into, the type.
Description of changes: This PR adds the JsonShapeDeserializer for schema-driven JSON deserialization, adds TimestampFormatTrait and fixes double/float precision
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.