@@ -2,6 +2,7 @@ extern crate reqwest;
22extern crate serde_json;
33
44use std:: fmt:: { Display , Error , Formatter } ;
5+ use serde_json:: Value ;
56
67const PROBLEMS_URL : & str = "https://leetcode.com/api/problems/algorithms/" ;
78const GRAPHQL_URL : & str = "https://leetcode.com/graphql" ;
@@ -43,7 +44,10 @@ pub fn get_problem(frontend_question_id: u32) -> Option<Problem> {
4344 sample_test_case : resp. data . question . sample_test_case ,
4445 difficulty : problem. difficulty . to_string ( ) ,
4546 question_id : problem. stat . frontend_question_id ,
46- return_type : serde_json:: from_str ( & resp. data . question . meta_data . return_info . type_name ) . unwrap ( ) ,
47+ return_type : {
48+ let v: Value = serde_json:: from_str ( & resp. data . question . meta_data ) . unwrap ( ) ;
49+ v[ "return" ] [ "type" ] . to_string ( ) . as_str ( ) . replace ( "\" " , "" ) . to_string ( )
50+ } ,
4751 } ) ;
4852 }
4953 }
@@ -113,21 +117,7 @@ struct Question {
113117 #[ serde( rename = "sampleTestCase" ) ]
114118 sample_test_case : String ,
115119 #[ serde( rename = "metaData" ) ]
116- meta_data : MetaData ,
117- }
118-
119- #[ derive( Debug , Serialize , Deserialize ) ]
120- struct MetaData {
121- name : String ,
122- params : String ,
123- return_info : ReturnInfo ,
124- }
125-
126- #[ derive( Debug , Serialize , Deserialize ) ]
127- struct ReturnInfo {
128- #[ serde( rename = "type" ) ]
129- type_name : String ,
130- params : String ,
120+ meta_data : String ,
131121}
132122
133123#[ derive( Debug , Serialize , Deserialize ) ]
0 commit comments