pub fn core_from_json(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 1 {
            print_error(chunk, i, "from-json requires one argument");
            return 0;
        }

        let value_rr = self.stack.pop().unwrap();
        let value_rrb = value_rr.borrow();
        let value_pre = value_rrb.to_string();
        let value_opt = to_string_2(&value_pre);

        match value_opt {
            Some(s) => {
                let doc_res = serde_json::from_str(s);
                let doc;
                match doc_res {
                    Err(e) => {
                        let err_str =
                            format!("unable to parse JSON: {}", e.to_string());
                        print_error(chunk, i, &err_str);
                        return 0;
                    }
                    Ok(d) => {
                        doc = d;
                    }
                }
                let json_rr = Rc::new(RefCell::new(convert_from_json(&doc)));
                self.stack.push(json_rr);
            }
            _ => {
                print_error(chunk, i, "from-json argument must be string");
                return 0;
            }
        }
        return 1;
    }
/// Takes a JSON string, converts it into a hash, and puts the
/// result onto the stack.
Takes a JSON string, converts it into a hash, and puts the
result onto the stack.
Takes a JSON string converts it into a hash and puts the result onto the stack .
pub fn core_from_json(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 1 {
            print_error(chunk, i, "from-json requires one argument");
            return 0;
        }
        let value_rr = self.stack.pop().unwrap();
        let value_rrb = value_rr.borrow();
        let value_pre = value_rrb.to_string();
        let value_opt = to_string_2(&value_pre);
        match value_opt {
            Some(s) => {
                let doc_res = serde_json::from_str(s);
                let doc;
                match doc_res {
                    Err(e) => {
                        let err_str =
                            format!("unable to parse JSON: {}", e.to_string());
                        print_error(chunk, i, &err_str);
                        return 0;
                    }
                    Ok(d) => {
                        doc = d;
                    }
                }
                let json_rr = Rc::new(RefCell::new(convert_from_json(&doc)));
                self.stack.push(json_rr);
            }
            _ => {
                print_error(chunk, i, "from-json argument must be string");
                return 0;
            }
        }
        return 1;
    }
pub fn core_from_json ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 1 { print_error ( chunk , i , " " ) ; return 0 ; } let value_rr = self . stack . pop ( ) . unwrap ( ) ; let value_rrb = value_rr . borrow ( ) ; let value_pre = value_rrb . to_string ( ) ; let value_opt = to_string_2 ( & value_pre ) ; match value_opt { Some ( s ) => { let doc_res = serde_json :: from_str ( s ) ; let doc ; match doc_res { Err ( e ) => { let err_str = format ! ( " " e to_string ( ) ) ; print_error ( chunk , i , & err_str ) ; return 0 ; } Ok ( d ) => { doc = d ; } } let json_rr = Rc :: new ( RefCell :: new ( convert_from_json ( & doc ) ) ) ; self . stack . push ( json_rr ) ; } _ => { print_error ( chunk , i , " " ) ; return 0 ; } } return 1 ; }
Takes a JSON string, converts it into a hash, and puts the
result onto the stack.
Takes a JSON string converts it into a hash and puts the result onto the stack .
&mut self
chunk
&Chunk
i
usize