0

I am using GSettings in my JS code to store some data. Now i need to store an array of array of strings, something like this:

var arr1 = new Array();
for (var index in list) {
    arr1[index] = new Array();

    arr1[index].push(list[index].blablaString);

    arr1[index] = arr1[index].concat(list[index].moreblablaStrings));
}

I know how to store array of strings in GSettings schema, but i got some problem to convert this array of array into variant obj, i try this:

var tmpVariant = GLib.Variant.new_objv(arr1);

and in gschema i create this key:

    <key name="tmparray" type="a(ss)">
        <default>[]</default>
    </key>

the error i got is this

had error: Error: Invalid element in string array

So, how can i store a matrix of strings in GSettings? thx

  • 1
    "a(ss)" means "array of struct, where struct contains two strings". If you really want array of array of string, that should be "aas". – Jussi Kukkonen Jan 23 '16 at 18:52
  • after change the key gschema i use GLib.Variant(TYPE, OBJ) constructor to create my variant obj and all works well: **var tmpVariant = new GLib.Variant('aas', arr1);** thx for your advice. – goodguyAbaddon Jan 24 '16 at 14:32

0 Answers0