Skip to content

Working with google.protobuf.Any in newest version #764

Open
@manni83

Description

@manni83

In #677 a wrapper for google.protobuf.Any was added. I wanted to use this because it would be very convenient when working with protobuf.Any, but it did not work. Here is an example based on the unit test comp_google_protobuf_any.js what I would like to do:

    foo = Foo.fromObject({
        foo: {
            "@type": ".Bar",
            bar: "a"
        }
    });

    test.ok(foo.foo instanceof Bar.ctor, "should unwrap wrapped Bar in fromObject");
  
    // Encode and decode again -> foo.foo is not serialized!
    var foo2 = Foo.decode(Foo.encode(foo).finish());
    obj = foo2.toObject(foo2, { json: true });

    // This fails
    test.same(obj.foo, { "@type": ".Bar", bar: "a" }, "this does not work at the moment");

Or is there any other way how I can initialize a message that contains a google.protobuf.Any easily?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions