from_json

Function from_json 

Source
pub fn from_json(json: &str) -> Result<BEMBlock, Error>
Expand description

Converts a JSON string into a BEMBlock.

This function takes a JSON string and deserializes it into a BEMBlock. It returns a Result containing the BEMBlock if the conversion is successful, or a serde_json::Error if there is a problem during deserialization.

§Arguments

  • json: &str - The JSON string to be converted to a BEMBlock.

§Returns

  • Result<BEMBlock, serde_json::Error> - A result containing the BEMBlock or an error.

§Examples

use bem::{BEMBlock, from_json};

let json = "{\"name\":\"media-player\",\"modifiers\":[],\"elements\":[]}";
let bem_block = from_json(json).unwrap();