Re: How to create vector of strings in javascript (TypeScript) Flatbuffers?

26 views
Skip to first unread message

Wouter van Oortmerssen

unread,
Sep 7, 2017, 3:04:59 PM9/7/17
to Tomas Ciboch, FlatBuffers
Like I already noted on your similar question here: https://stackoverflow.com/questions/46043360/how-to-create-vector-of-strings-in-javascript-typescript-flatbuffers#comment79057045_46043360

You'll have to first explain what exactly is not working.

On Mon, Sep 4, 2017 at 1:24 PM, Tomas Ciboch <t.ci...@gmail.com> wrote:

is there any way how to create vector of strings in TypeScript? I already tried lot of things but nothing worked.

I evean tried to created "covering tabel in schema StringArray" like this:

table StringArray { items:[string]; }

And I'm trying to use it like this:

let builder: flatbuffers.Builder = new flatbuffers.Builder();


let offsets : Array<flatbuffers.Offset>;
offsets = new Array<flatbuffers.Offset>(2);

offsets[0] = builder.createString("hello");
offsets[1] = builder.createString("world");

let offsetOfStrings = messaging.StringArray.createItemsVector(builder, offsets);

// create message
messaging.StringArray.startStringArray(builder);
messaging.StringArray.addItems(builder, offsetOfStrings);
let serialized = messaging.Message.endMessage(builder);

builder.finish(serialized);
let data = builder.asUint8Array();

But without any success, can you someone help me please?

--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages