Skip to content

Instantly share code, notes, and snippets.

@zebulon988
zebulon988 / js-class-decorator-new-constructor.ts
Created Aug 29, 2019
how to create a new constructor which wrap the old
View js-class-decorator-new-constructor.ts
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@zebulon988
zebulon988 / JavaJsonObjectDeserializerTest.java
Last active Dec 24, 2016
FastJson serialize and deserialize org.json.JSONObject and org.json.JSONArray
View JavaJsonObjectDeserializerTest.java
package zebulon.test.zebulon.test.fastjson;
import android.text.TextUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.alibaba.fastjson.serializer.JSONSerializer;
@zebulon988
zebulon988 / StringJsUtil.java
Created Nov 26, 2016
java code call js method which has string params ,you should wrap the string
View StringJsUtil.java
public static String wrapStringForJsCallParams(String str){
if(TextUtils.isEmpty(str)) return str;
str = str.replaceAll("\\\\" , "\\\\\\\\");
str = str.replaceAll("'" , "\\\\'");
str = str.replaceAll("\"" , "\\\\\"");
return str;
}