Embedded rust with json and 3 levels plus strings

We are using no_std and using serde_json_core. The problem is that when the json goes down to third level it wont read when we have &'a str. It works when we only use uints. The program just stops when it is filling the structs with the json information.

use hal::entry;
use serde::{Serialize, Deserialize};
use serde_json_core;
use esp_println::println;
use core::str::{self, Bytes};
use heapless::String;
use heapless::Vec;

#[derive(Serialize, Deserialize, Debug)]
pub struct foo<'a>{
    pub baar :  &'a str,

#[derive(Serialize, Deserialize, Debug)]
pub struct date_and_booking_array <'a> {
    pub Date: &'a str,
    pub BookingArray: Vec<foo<'a>,200>

#[derive(Serialize, Deserialize, Debug)]
pub struct room_id_and_date_array <'a> {
    pub RoomID: u32,
    pub DateArray: Vec<date_and_booking_array<'a>, 30>

fn panic(_info: &core::panic::PanicInfo) -> ! {
    loop {
        // Add any custom panic handling logic here

fn main() -> ! {
    // Deserialization
    let test_data: &str =
    "RoomID": 1,
    "DateArray": [
            "Date": "2023-10-26",
            "BookingArray": [
                {"baar": "7"}   
    println!("{}", test_data);
    let booking: Result<(room_id_and_date_array<'static>, usize), serde_json_core::de::Error> = serde_json_core::from_str::<room_id_and_date_array>(test_data);
    match booking {
        Ok(res) => { println!("Success:\n{:?}", res); },
        Err(e) => { println!("Failed with error: {:?}", e) }
    loop { }

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.