Skip to content

Adding JsonShapeDeserializer - #3889

Open
pulimsr wants to merge 1 commit into
mainfrom
schema-serde
Open

Adding JsonShapeDeserializer#3889
pulimsr wants to merge 1 commit into
mainfrom
schema-serde

Conversation

@pulimsr

@pulimsr pulimsr commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Description of changes: This PR adds the JsonShapeDeserializer for schema-driven JSON deserialization, adds TimestampFormatTrait and fixes double/float precision

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pulimsr
pulimsr marked this pull request as ready for review August 3, 2026 14:24

size_t BeginStruct() {
auto tok = NextToken();
if (tok != Token::ObjectStart) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants