Hello !

Require some guidance on how to write a CBOR parsing implementation for the 
following structure.

{a:[1,2,3,4], b:[ {c:[1,2,3,4,5]}, {c:[1,2,3,4,5]}]}

I tried the following implementation.
———————————————————————————————————————————————————————

uint64_t a[5];
Int a_count = 0;

struct c_object{
        int c[6];
}c_arr_objs[5];
int c_obj_count = 0;

struct cbor_attr_t c_attrs[] = {
    {
        .attribute = “c",
        .type = CborAttrObjectType,
        CBORATTR_STRUCT_OBJECT(struct c_object, c),
        .dflt.integer = 0
    },
    {
        .attribute = NULL
    }
};


struct cbor_attr_t root_attrs[] = {
    {
        .attribute = “a",
        .type = CborAttrArrayType,
        .addr.array.element_type = CborAttrUnsignedIntegerType,
        .addr.array.arr.uintegers.store = a,
        .addr.array.count = &a_count,
        .addr.array.maxlen = sizeof(a) / sizeof(a[0]),
        .nodefault = true
    },
    {
        .attribute = “b",
        .type = CborAttrArrayType,
        CBORATTR_STRUCT_ARRAY(c_arr_objs, c_attrs, &c_obj_count),
        .nodefault = true
    },
    {
        .attribute = NULL
    }
};

———————————————————————————————————————————————————————


I assumed this to work as I have been using the same albeit without ‘c’ being a 
int Array. It works when I use ‘c’ as a Int etc, but not as a int Array, 

The example :- 
https://github.com/apache/mynewt-core/blob/master/encoding/cborattr/test/src/testcases/cborattr_decode_object_array.c
 
<https://github.com/apache/mynewt-core/blob/master/encoding/cborattr/test/src/testcases/cborattr_decode_object_array.c>

Has a similar implementation for Text String instead of Int Array.

Thanks,
Aditya Xavier.



Reply via email to