You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm struggling with documentation in Chinese language, please help.
I'm trying to migrate from jackson to fastjson2, and I'm stuck with a few questions I can't find answers to:
Can you please tell me, whether fastjson2 is threadsafe (may I serialize different objects from different thrads via JSON / JSONObject static methods?), and if it's not, how can I achieve thread-safety?
I'm trying to migrate from jackson to fastjson2. Are there (if any) direct equivalents of the following functions from jackson in fastjson2:
jackson's ObjectReader.readerForUpdating(b): where I provide a builder, and then parse new json's values with respect to values already present in that builder
jackson's JsonNode: I'd like to have something like JSONObject, which might be either JSONArray or JSONObject, but I can't find a way to differ one from another, like, if I just have a String and I want to get either a single JSONObject or an array of JSONObjects
The text was updated successfully, but these errors were encountered:
Thank you for choosing fastjson2, I hope it helps you.
The static methods provided by the JSON class are thread-safe, you don't have to worry about that.
Do you think this is what you want?
public class Int1 {
public int v0000;
}
String str = "{\"v0000\":101}";
Int1 vo = new Int1();
JSONReader jsonReader = JSONReader.of(str);
jsonReader.readObject(vo);
assertEquals(101, vo.getV0000());
Thank you for choosing fastjson2, I hope it helps you.
The static methods provided by the JSON class are thread-safe, you don't have to worry about that.
Do you think this is what you want?
public class Int1 {
public int v0000;
}
String str = "{\"v0000\":101}";
Int1 vo = new Int1();
JSONReader jsonReader = JSONReader.of(str);
jsonReader.readObject(vo);
assertEquals(101, vo.getV0000());
Thank you for your quick answer!
Great!
Is it true, that str may not have all the fields of Int1? May it have only REQUIRED or even a subset of REQUIRED fields? Also I really need some kind of common interface between JSONArray and JSONObject to dynamically decide whether underlying JSO is an array or a simple object
str may not include any Int1 fields. If there are extra fields, they will be ignored. If you want to process extra fields, you can configure ExtraProcessor, for example:
Questions
Hello, I'm struggling with documentation in Chinese language, please help.
I'm trying to migrate from jackson to fastjson2, and I'm stuck with a few questions I can't find answers to:
JSON
/JSONObject
static methods?), and if it's not, how can I achieve thread-safety?ObjectReader.readerForUpdating(b)
: where I provide a builder, and then parse new json's values with respect to values already present in that builderJsonNode
: I'd like to have something likeJSONObject
, which might be eitherJSONArray
orJSONObject
, but I can't find a way to differ one from another, like, if I just have aString
and I want to get either a singleJSONObject
or an array ofJSONObjects
The text was updated successfully, but these errors were encountered: