com.alibaba.fastjson2.support.airlift.JSONFunctions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fastjson2-extension Show documentation
Show all versions of fastjson2-extension Show documentation
Fastjson is a JSON processor (JSON parser + JSON generator) written in Java
package com.alibaba.fastjson2.support.airlift;
import com.alibaba.fastjson2.JSONPath;
import com.alibaba.fastjson2.JSONReader;
import io.airlift.slice.Slice;
public class JSONFunctions {
public static Slice jsonExtract(Slice json, JSONPath path) {
byte[] bytes = json.byteArray();
int off = json.byteArrayOffset();
int length = json.length();
JSONReader jsonReader = JSONReader.of(bytes, off, length);
SliceValueConsumer sliceValueConsumer = new SliceValueConsumer();
path.extract(jsonReader, sliceValueConsumer);
return sliceValueConsumer.slice;
}
}