移植jsoncpp到安卓
发布时间:2020-12-16 19:03:21 所属栏目:百科 来源:网络整理
导读:1.我使用的方法是静态库的方式,因为动态库的方式一直无法在我的OPPO运行,如果你是使用java来加载的那么推荐你使用动态库运行,我这里为了测试方便,直接在OPPO手机运行C的 这里我基于jsoncpp移植的库,稍后上传,我只是修改了其中的exception,因为ndk并不完全支
1.我使用的方法是静态库的方式,因为动态库的方式一直无法在我的OPPO运行,如果你是使用java来加载的那么推荐你使用动态库运行,我这里为了测试方便,直接在OPPO手机运行C的 这里我基于jsoncpp移植的库,稍后上传,我只是修改了其中的exception,因为ndk并不完全支持C++ 链接:https://github.com/2637309949/CODE_NDK_C-_C LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := main # Add your application source files here... LOCAL_SRC_FILES := main.cpp LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog LOCAL_STATIC_LIBRARIES := libJson include $(BUILD_EXECUTABLE) $(call import-module,jsoncpp-0.5.0)
#include <stdio.h> #include <string> #include <json/json.h> using namespace std; int main(int argc,char **argv) { printf("%sn","start..."); Json::Value root; Json::Value arrayObj; Json::Value item; for(int i=0;i<5;i++){ char buffer[20]; sprintf(buffer,"key%d",i); item[buffer] = i; arrayObj.append(item); } root["key1"] = "value1"; root["key2"] = "value1"; root["array"] = arrayObj; //生成string json std::string out = root.toStyledString(); std::cout << out << std::endl; //一些有用的api std::cout << root.size() <<std::endl;; std::cout << root.removeMember("key2") <<std::endl;; std::cout << root.toStyledString() <<std::endl;; return 1; }
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |