• 微软开源 C++ REST SDK


    微软开源 C++ REST SDK

    投递人 itwriter 发布于 2013-02-28 16:31 评论(0) 有111人阅读  原文链接  [收藏]  « »

      微软近日开源了C++ REST SDK,托管在自己的 CodePlex 平台上。 

      项目地址:http://casablanca.codeplex.com 

      C++ REST SDK 包含在 Casablanca 项目中。Casablanca 是一个 C++ 本地库,旨在帮助开发者的 C++ 应用程序访问云服务。如果你想编写一个响应式的 C++ 客户端应用程序,或者是一个可扩展的服务端解决方案,可以试试 Casablanca。除了C++ REST SDK 外,Casablanca 项目还包含 Azure SDK for C++。 

      C++ REST SDK 中包含了一些工具,可以帮助开发者快速编写现代、异步、可连接 REST 服务的 C++ 应用程序,遵循C++11 标准,目前支持 Windows 7、Windows 8(包括 Windows Store 和桌面应用)和 Linux。 

      该 SDK 的主要特性包括: 

    • 能够通过 HTTP Client 创建服务器连接,并发送请求、处理响应
    • 支持构造和使用 URI(Uniform Resource Identifiers,统一资源标识符)
    • 构造、解析和序列化 JSON 值
    • 通过 Streams 和 Stream Buffers 从底层介质异步读取/写入字节

      下面的示例演示了如何上传文件到 HTTP 服务器:

    #include <json.h>
    
    int main ()
    {
      // Create a JSON object.   json::value obj;
      obj[L"key1"] = json::value::boolean (false);
      obj[L"key2"] = json::value::number (44);
      obj[L"key3"] = json::value::number (43.6);
      obj[L"key4"] = json::value::string(U("str"));
    
      // Loop over each element in the object. for(auto iter = obj.cbegin (); iter != obj.cend (); ++iter)
      {
        // Make sure to get the value as const reference otherwise you will end up copying
        // the whole JSON value recursively which can be expensive if it is a nested object. const json::value &str = iter->first;
        const json::value &v = iter->second;
    
        // Perform actions here to process each string and value in the JSON object... wprintf (L"String:%s", str.as_string ());
        wprintf (L"Value:%s", v.to_string ());
      }
      return 0;
    }

      下面的示例演示了如何构建并遍历 JSON 值:

    #include <json.h>
    
    int main ()
    {
      // Create a JSON object.   json::value obj;
      obj[L"key1"] = json::value::boolean (false);
      obj[L"key2"] = json::value::number (44);
      obj[L"key3"] = json::value::number (43.6);
      obj[L"key4"] = json::value::string(U("str"));
    
      // Loop over each element in the object. for(auto iter = obj.cbegin (); iter != obj.cend (); ++iter)
      {
        // Make sure to get the value as const reference otherwise you will end up copying
        // the whole JSON value recursively which can be expensive if it is a nested object. const json::value &str = iter->first;
        const json::value &v = iter->second;
    
        // Perform actions here to process each string and value in the JSON object... wprintf (L"String:%s", str.as_string ());
        wprintf (L"Value:%s", v.to_string ());
      }
      return 0;
    }

      详细信息:The C++ REST SDK ("Casablanca")

  • 相关阅读:
    Codeforces 1439B. Graph Subset Problem (思维,复杂度分析)
    石子游戏(nim游戏+按位考虑)
    Codeforces 1437F Emotional Fishermen(思维,dp)
    Codeforces Round #671 (Div. 2) (A~E)
    Java就业企业面试问题ssh框架
    DUBBO初探搭建DUBBO开发环境
    Spring容器组建注解@Component和Resouces实现完全注解配置
    jUnit 4 在 s2sh 中的应用
    4.5、常量、作用域、内置全局变量
    Java 诗词纵向转换字符流输出
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/2938114.html
Copyright © 2020-2023  润新知