修改postman工具的代码生成工具让它锦上添花 (2)

定位到632行 这里是生成csharp代码

//下面加入jsonPOJO的代码 try { var input = localStorage.getItem('_current_reponse_json'); var code = ''; if(input){ var requestType = { input : input, operationid:"jsontocsharp", settings:{ UsePascalCase:true, UseJsonAttributes:false, UseFields:false, UseJsonPropertyName:false } }; var data = JSON.stringify(requestType); var xhr = new XMLHttpRequest(); xhr.addEventListener("readystatechange", function() { if(this.readyState === 4) { var next = false; var result = []; for(var i = 0;i< this.responseText.length;i++) { var item = this.responseText[i]; if(item == '\"'){} else if(item == "\\" || item == "http://www.likecs.com/"){next = true} else if(next){next = false,result.push("\n")} else{result.push(item)} } code= '\n //Deserialize json response to POJO \n'+result.join("").replace('myJsonResponse','response.Content'); } }); xhr.onerror = function () { return callback(null, headerSnippet + snippet + footerSnippet); } xhr.open("POST", "https://json2csharp.com/api/Default",false); xhr.setRequestHeader("Accept", "*/*"); xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); xhr.setRequestHeader('Content-type', 'application/json'); xhr.send(data); return callback(null, headerSnippet + snippet + code + footerSnippet); } } catch (e) { return callback(null, headerSnippet + snippet + footerSnippet); }

定位到16668行 这里是生成java代码

//下面加入jsonPOJO的代码 try { var input = localStorage.getItem('_current_reponse_json'); var code = ''; if(input){ var requestType = { input : input, operationid:"jsontopojo", settings:{ UseProperties:false } }; var data = JSON.stringify(requestType); var xhr = new XMLHttpRequest(); xhr.addEventListener("readystatechange", function() { if(this.readyState === 4) { var next = false; var result = []; for(var i = 0;i< this.responseText.length;i++) { var item = this.responseText[i]; if(item == '\"'){} else if(item == "\\"){next = true} else if(next){next = false,result.push("\n")} else{result.push(item)} } code= '\n //Deserialize json response to POJO \n'+result.join("").replace('myJsonResponse','response.Content'); } }); xhr.onerror = function () { return callback(null, headerSnippet + snippet + footerSnippet); } xhr.open("POST", "https://json2csharp.com/api/Default",false); xhr.setRequestHeader("Accept", "*/*"); xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); xhr.setRequestHeader('Content-type', 'application/json'); xhr.send(data); snippet = snippet + code; } } catch (e) { }

image

5.源码修改后重新打包成asar文件 asar pack app app.asar

搞定验证结果 java的方式

csharp的方式

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wppfps.html