好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

微软开源 C++ REST SDK

微软开源 C++ REST SDK

微软开源 C++ REST SDK

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

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

  项目地址: http://casablanca.codeplex测试数据  

  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")

0

0

 

 

来自:  HdhCmsTestiteye测试数据

 

找优秀程序员,就在博客园

作者: Leo_wl

    

出处: http://HdhCmsTestcnblogs测试数据/Leo_wl/

    

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

版权信息

查看更多关于微软开源 C++ REST SDK的详细内容...

  阅读:39次