Questions tagged [fastjson]

A fast JSON parser/generator for Java, or a smallest, fastest polymorphic JSON serializer for C#.

Fastjson(disambiguation)

java

Fastjson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Fastjson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of.

C#

Fastjson is the smallest and fastest polymorphic JSON serializer.

49 questions
1
vote
2 answers

Deserialized part data using fastJSON fail

I want deserialized part data using fastJSON fail. class A { public String a; } The data {"a": "a", "b": "b" } Use A objectA = JSON.parseObject(data, A.class) get objectA, but the field of a is null. If I fill the class to class A { …
Pitty
  • 329
  • 4
  • 15
1
vote
1 answer

How to ignore params when `parseObject` in fastjson?

I use the fastjson to deal with the JSON. When I was trying to derialize the JSON string to a bean, I got an exception. I debuged into the code and find out there was something wrong with a param when deserializeing. So I wanna ignore it. I used the…
blackdog
  • 2,007
  • 3
  • 25
  • 43
1
vote
0 answers

fastJSON exception 'Serializer encountered maximum depth of 20'

I'm using fastjson to serialize an object before I pass it back from my controller to my $.post call in javascript, but I'm getting this error and I don't know why. The exception is being thrown when I try to call 'fastJSON.JSON.ToJSON(contact)',…
chuckd
  • 13,460
  • 29
  • 152
  • 331
1
vote
0 answers

How do I use the deserialized data using fastJSON?

I've got this code that retrieves json data from a WebAPI method and then puts it in a string: const string uri = "http://localhost:48614/api/departments"; var webRequest = (HttpWebRequest)WebRequest.Create(uri); var webResponse =…
0
votes
3 answers

fastJSON ToJSON into dictionary?

How to use fastJSON (or some other JSON lib, possibly) to dump some data into a dictionary format, e.g. {"key1": "valstring", "key2": 1234}? If I try to dump Dictionary I get something like…
HoverHell
  • 4,739
  • 3
  • 21
  • 23
0
votes
0 answers

dubbo use fastjson2 Serialize error autotype not support

java.io.IOException: org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: auotype not support when provider return a generics dto,the server throw this exception when I use dubbo 3.2.5, find this problem,how…
0
votes
1 answer

Why Class.java don't provide methods like `Type getType()` and `Type getGenericType()`?

Why I have to define a subclass to get the Type of superclass' generic param? Is the limit necessary? I read the code of Fastjson of Alibaba and tried to figure out why use TypeReference must create an anonymous subclass. Then I found that an object…
0
votes
0 answers

Why can't this text be parsed through fastjson2?

import com.alibaba.fastjson2.JSONArray JSONArray.parseArray(str).toString() I use the toString method of fastjson2 to parse this JSON string, but I will encounter an error: Caused by: java.lang.ArrayIndexOutOfBoundsException: 1024 at…
datagic
  • 25
  • 7
0
votes
1 answer

in flink, I can`t map String to JSONObject

source code: source a String,and I try to map it into JSONObject,and i failed. public class Test { public static void main(String\[\] args) throws Exception { //TODO 1. StreamExecutionEnvironment env =…
0
votes
1 answer

JMeter failed to keep JSON order by using fastjson JSONObject.parseObject

Backgroud: In Jmeter, I need to get the json post data, and then parse to the JSONObject But the key order should the same The json post data is: { "one": "1", "two": "2", "three": "3", "four": "4" } After JSON Object parse, it also should be: {…
Ken
  • 325
  • 3
  • 10
0
votes
0 answers

Parse map like json string into class by fastjson/jackson

Consider a json: { "data": { "key1": { "t1":"text1", "t2":"text1", }, "key2": { "t1":"text1", "t2":"text1", }, ... } "code": 1 } With data java class defined as below: @Getter @Setter public…
EthanAlef
  • 35
  • 6
0
votes
1 answer

How to change json string to LinkedList when using fastjson in Java?

I want to change the string into LinkedList,I write the code but it happen in to a exception,java.util.ArrayList cannot be cast to java.util.LinkedList,How to fix it? LinkedList names=new LinkedList(); names.add("a"); …
Rebecca
  • 199
  • 2
  • 8
0
votes
1 answer

De-serializing Exception with FastJSON: Can not set field to java.lang.Exception

I'm using FastJSON to serialize and de-serialize some classes. However, I've found a combination that doesn't work: An exception that contains holds a reference to an object from another class cannot be de-serialized. Example: import…
Green绿色
  • 1,620
  • 1
  • 16
  • 43
0
votes
1 answer

How to parse json to an object extends HashMap use fastjson in java?

I have a json, two custom beans, one of which extends HashMap. While I use com.alibaba.fastjson.JSON to parse json into the object extends HashMap and call the get method, it will get a ClassCastException. So I tested the ArrayList again, but there…
xmcx
  • 283
  • 3
  • 18
0
votes
1 answer

How to don't serialize the class field in FastJson?

Today I'm using FastJson(https://github.com/alibaba/fastjson), the following is my demo code. class User { private final String name; private final int age; private final String birthday; private String password; public User(String name,…
Yatao Wang
  • 16
  • 3