I think I have exhausted all the ways I can think of doing this. I need to return an Array to B4R from a library wrapper routine.
The current code:
The serial.print confirms that d[] does contain the values I want.
in the B4R code its called by
logging d(0) and d(1) always returns 2 and 3.1309 even though the 'data' is 48.756080 and 2.302038
The current code:
B4X:
B4R::Array* rJson::getArray(B4R::B4RString* key,B4R::Object* o)
{
JsonArray data = obj[(char*)key->data].as<JsonArray>();
B4R::Array* arr = (B4R::Array*)o->data.PointerField;
double d[(int)arr->length];
int a = 0;
for(JsonVariant v : data) {
d[a++] = v.as<double>();
::Serial.printf("%3.6f \r\n",d[a-1]);
}
arr->wrap(d,(unsigned int)2);
o = (B4R::Object*)arr;
return arr;
}
The serial.print confirms that d[] does contain the values I want.
in the B4R code its called by
B4X:
dim d[2] As Double
Json.getArray("data",d)
' I also tried d = Json.getArray("data",d) with the same results
logging d(0) and d(1) always returns 2 and 3.1309 even though the 'data' is 48.756080 and 2.302038