[System.Web.Http.HttpPost]
        public HttpResponseMessage GetProduct([FromBody] dynamic json)
        {
            var product = new { success = true, errorMsg = "", data = "" };
            string jsons = Convert.ToString(json);
            var products = Post(jsons);//调用接口方法
            ResultMsg res = JsonConvert.DeserializeObject<ResultMsg>(products);
            bool succ =Convert.ToBoolean( res.success.ToString());
            string mes = res.errorMsg.ToString();
            string dataa = res.data.ToString();
            if (succ==true)
            {
                 product = new { success = true, errorMsg = mes,data=dataa};
            }
            else
            {
                 product = new { success = false, errorMsg = mes, data = dataa };
            }
            HttpResponseMessage result = new HttpResponseMessage();
            result.Content = new StringContent(JsonConvert.SerializeObject(product), Encoding.GetEncoding("UTF-8"), "application/json");
            return result;
        }
json
适用于现代 C++ 的 JSON。

大概逻辑是调用这个方法,在此方法中在调用真正的接口方法,将返回值给设定一下格式基本就可以了。最基本的方法。

GitHub 加速计划 / js / json
41
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:6 个月前 )
9f40a7b4 Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.6.9 to 9.6.10. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.6.9...9.6.10) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 9 小时前
d41ca94f * :wrench: adjust CMake versions Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :wrench: install OpenSSL for CMake Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :wrench: install OpenSSL for CMake Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :wrench: install OpenSSL for CMake Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :wrench: install OpenSSL for CMake Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :wrench: install OpenSSL for CMake Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :hammer: clean up Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :memo: update documentation Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me> 9 小时前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐