@@ -2,6 +2,7 @@ extern crate reqwest;
2
2
extern crate serde_json;
3
3
4
4
use std:: fmt:: { Display , Error , Formatter } ;
5
+ use serde_json:: Value ;
5
6
6
7
const PROBLEMS_URL : & str = "https://leetcode.com/api/problems/algorithms/" ;
7
8
const GRAPHQL_URL : & str = "https://leetcode.com/graphql" ;
@@ -43,7 +44,10 @@ pub fn get_problem(frontend_question_id: u32) -> Option<Problem> {
43
44
sample_test_case : resp. data . question . sample_test_case ,
44
45
difficulty : problem. difficulty . to_string ( ) ,
45
46
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
+ } ,
47
51
} ) ;
48
52
}
49
53
}
@@ -113,21 +117,7 @@ struct Question {
113
117
#[ serde( rename = "sampleTestCase" ) ]
114
118
sample_test_case : String ,
115
119
#[ 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 ,
131
121
}
132
122
133
123
#[ derive( Debug , Serialize , Deserialize ) ]
0 commit comments