天道酬勤,学无止境

MSON

尝试使用 API Blueprint 中的数据结构来描述请求和响应(Trying to describe the request and response using Data Structures in API Blueprint)

问题 我正在尝试使用规范的新 Attributes 和 DataStructures 部分来记录带有 API Blueprint 的端点。 我的请求负载如下所示: { "url": "http://requestb.in/11v7i7e1", "active": true, "types": [ { "name": "sales", "version": "2.0" }, { "name": "products", "version": "2.0" } ] } 我的响应负载看起来像这样: { "data": { "id": "dc85058a-a683-11e4-ef46-e9431a15be8c", "url": "http://requestb.in/11v7i7e1", "active": true, "types": [ { "name": "products", "version": "2.0" }, { "name": "sales", "version": "2.0" } ] } } 我尝试了以下 API 蓝图降价: FORMAT: 1A # Vend REST API 2.0 # Group Webhooks ## api/2.0/webhooks [/webhooks] ### List all Webhooks [GET] Returns a list of

2021-11-29 17:34:54    分类:技术分享    api   apiblueprint   apiary.io   apiary   MSON

Trying to describe the request and response using Data Structures in API Blueprint

I'm trying to document an endpoint with API Blueprint, using the new Attributes and DataStructures sections of the spec. My request payload looks like this: { "url": "http://requestb.in/11v7i7e1", "active": true, "types": [ { "name": "sales", "version": "2.0" }, { "name": "products", "version": "2.0" } ] } My response payload looks something like that: { "data": { "id": "dc85058a-a683-11e4-ef46-e9431a15be8c", "url": "http://requestb.in/11v7i7e1", "active": true, "types": [ { "name": "products", "version": "2.0" }, { "name": "sales", "version": "2.0" } ] } } I tried the following API Blueprint

2021-11-21 17:46:02    分类:问答    api   apiblueprint   apiary.io   apiary   MSON

MSON在蓝图中描述对象属性(MSON to describe object attributes in blueprint)

问题 我有一个类似于这里描述的问题。 我有一个看起来像这样的 JSON: { "photos": [ { "key": "y37dmj10jkwof/moOIUB8912JKVgh", "caption": "A world of gamers.", "tags": [ "game", "japan" ], "attributes": { "copyright": true, "use": [ "public", "private" ] } } ] } 我正在尝试使用 MSON 描述属性,以呈现蓝图。 但是,我并不成功。 这是我的尝试: + Attributes (required, object) + photos (required, array) + (object) + key (required, string) - Photo key + caption (required, string) - Photo caption + tags (required, array) + game (string) + japan (string) + attributes (required, object) + (object) + copyright: true (required, boolean) + uses (required, array) + public

2021-09-23 18:36:38    分类:技术分享    apiblueprint   apiary.io   apiary   MSON

MSON to describe object attributes in blueprint

I have an issue similar to what is described here. I have a JSON that looks like this: { "photos": [ { "key": "y37dmj10jkwof/moOIUB8912JKVgh", "caption": "A world of gamers.", "tags": [ "game", "japan" ], "attributes": { "copyright": true, "use": [ "public", "private" ] } } ] } and I am trying to describe the attributes using MSON, to render the blueprint. However, I am not successful at it. Here is my attempt: + Attributes (required, object) + photos (required, array) + (object) + key (required, string) - Photo key + caption (required, string) - Photo caption + tags (required, array) + game

2021-06-28 18:52:30    分类:问答    apiblueprint   apiary.io   apiary   MSON

MSON,让JSON序列化更快

问题我们经常需要在主线程中读取一些配置文件或者缓存数据,最常用的结构化存储数据的方式就是将对象序列化为JSON字符串保存起来,这种方式特别简单而且可以和SharedPrefrence配合使用,因此应用广泛。但是目前用到的Gson在序列化JSON时很慢,在读取解析这些必要的配置文件时性能不佳,导致卡顿启动速度减慢等问题。Gson的问题在哪里呢?笔者用AndroidStudio的profile工具分析了activity.onCreate方法的耗时情况。图 1图 2如图1,可以发现Gson序列化占用了大部分的执行时间,从图2可以更直观地看到Gson.fromJson占用了61%的执行时间。分析Gson的源码可以发现,它在序列化时大量使用了反射,每一个field,每一个get、set都需要用反射,由此带来了性能问题。如何优化知道了性能的瓶颈之后,我们如何去修改呢?我能想到的方法就是尽量减少反射。Android框架中由JSONObject来提供轻量级的JSON序列化工具,所以我选择用Android框架中的JSONObject来做序列化,然后手动复制到bean就可以去掉所有的反射。我做了个简单的测试,分别用Gson和JSONObject的方式去序列化一个bean,看下各自速度如何。使用JSONObject的实现方式如下:public class Bean { public String key

2021-06-02 03:42:59    分类:博客    MSON   JSON序列化