We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, i have problem with jansson pack. when i run the example code in simulator its output is correct as expected but when i change the device to for example stm32f103 the output is empty curly brackets {}; the example code is :
void add_2array_to_json( json_t* obj, const char* name, const int* marr, size_t dim1, size_t dim2 ) { size_t i, j; json_t* jarr1 = json_array(); for( i=0; i<dim1; ++i ) { json_t* jarr2 = json_array(); for( j=0; j<dim2; ++j ) { int val = marr[ i*dim2 + j ]; json_t* jval = json_integer( val ); json_array_append_new( jarr2, jval ); } json_array_append_new( jarr1, jarr2 ); } json_object_set_new( obj, name, jarr1 ); return; } void SystemClock_Config(void); static json_t* jdata; int main() { char* s; int arr1[2][3] = { {1,2,3}, {4,5,6} }; int arr2[4][4] = { {1,2,3,4}, {5,6,7,8}, {9,10,11,12}, {13,14,15,16} }; char ss[128]; /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_USART1_UART_Init(); json_object_seed(1); jdata = json_object(); add_2array_to_json( jdata, "arr1", &arr1[0][0], 2, 3 ); add_2array_to_json( jdata, "arr2", &arr2[0][0], 4, 4 ); s = json_dumps( jdata, 0 ); HAL_UART_Transmit(&huart1,(uint8_t*)s,strlen(s),1000); // puts( s ); free( s ); json_decref( jdata ); while(1){ HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_13); HAL_Delay(200); }; }
i used jansson v2.7 and also the latest v2.9. both the same am i wrong?