Giter Site home page Giter Site logo

jd-open-api-sdk-src's Introduction

京东云开放API的SDK源码

为了深入了解京东开放平台提供的SDK,我将他们提供的SDK反编译后,重新整理了一份SDK的源码。

获得了源码后,首先我感受到的是这个SDK实现比较简单,主要功能就是将Java对象编码为JSON处理收发消息,难点至于接口比较多,参数也比较多。

因为这个SDK基本上没有什么业务逻辑,所以完全可以使用另外的方式重新开发一套SDK出来。

比如我们可以使用Java JSON Binding的方式动态绑定,这样我们就不用编写domainrequestresponsePOJO的类了,或者使用工具自动生成POJO类。

为了重写这个SDK,我首先需要获取SDK的所有的接口的详细信息,然后整理为一个统一的JSON文档,运行时自动的根据这个JSON文档来编解码消息。

下面是我设计一个简单的API文档格式。

{
	"api-suit-name": "jd-open-api-sdk",
	"version": "2.0.0",
	"provider": "http://help.jd.com/jos/question-594.html",
	"api": {
		"group": "address",
		"name": "AreaCityGetRequest",
		"method": "jingdong.area.city.get",
		"request": {
			"parentId": "Long"
		},
		"response": {
			"cityAreas": [ "AreaListBeanVO[]" ],
			"success": "Boolean"
		}
	}
}

我运用Java的反射机制写了一个简单的JdApiExporter用于将源码里面所有JdRequest请求和响应接口都导出为这个JSON文档。

jd-open-api-sdk-src's People

Contributors

pingjiang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.