Skip to content

Instantly share code, notes, and snippets.

@zebulon988
zebulon988 / StringJsUtil.java
Created November 26, 2016 06:19
java code call js method which has string params ,you should wrap the string
public static String wrapStringForJsCallParams(String str){
if(TextUtils.isEmpty(str)) return str;
str = str.replaceAll("\\\\" , "\\\\\\\\");
str = str.replaceAll("'" , "\\\\'");
str = str.replaceAll("\"" , "\\\\\"");
return str;
}
@zebulon988
zebulon988 / JavaJsonObjectDeserializerTest.java
Last active December 24, 2016 15:15
FastJson serialize and deserialize org.json.JSONObject and org.json.JSONArray
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 / js-class-decorator-new-constructor.ts
Created August 29, 2019 01:54
how to create a new constructor which wrap the old
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);
}