SHARE
TWEET

Untitled

a guest Jul 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extern crate serde;
  2. extern crate serde_json;
  3.  
  4. use serde_json::Value;
  5.  
  6. struct DataIds
  7. {
  8.     data: Vec<String>
  9. }
  10.  
  11. fn main() {
  12.     let jstr = r#"
  13.     {
  14.     "data": [["foo", "bar"], ["foo1", "bar1"]]
  15.        
  16.     }"#;
  17.  
  18.     let jvalue: Value = serde_json::from_str(jstr).unwrap();
  19.     let jarray: Vec<_> = jvalue["data"].as_array().unwrap().to_vec();
  20.  
  21.     let jarray: Vec<_> = jarray.into_iter().map(|v| v.as_str().unwrap()).collect();
  22.     println!("{}", jarray)
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top