Comments (5)
hey @ReggieLei, can you share more details & steps to reproduce the issue.
from pluto.
Right back
[{
"deviceId": "905436c790da4766a1c8e7d213f6a765",
"deviceCode": "NIC1C2206022",
"fourGOnline": 0,
"wifiOnline": 1,
"bluetoothOnline": 1,
"wifiStrength": 18,
"fourGStrength": 0,
"pileStatus": -1,
"isAdmin": 1,
"isForbid": 1,
}]
pluto catch back
RESPONSE
*** Body ***
[
{
"deviceId": "905436c790da4766a1c8e7d213f6a765",
"deviceCode": "NIC1C2206022",
"fourGOnline": 0.0,
"wifiOnline": 1.0,
"bluetoothOnline": 1.0,
"wifiStrength": 18.0,
"fourGStrength": 0.0,
"pileStatus": -1.0,
"isAdmin": 1.0,
"isForbid": 1.0,
}
]
report generated by Pluto (https://plutolib.com)
All Int is converted to double
from pluto.
thanks for posting the issue @ReggieLei .
JSON is a type agnostic representation. As per official JSON docs
JSON does not have distinct types for integers and floating-point values. Therefore, the presence or absence of a decimal point is not enough to distinguish between integers and non-integers.
https://json-schema.org/understanding-json-schema/reference/numeric.html
That said, we ll definitely look into it, if we can differentiate between Integer & Double.
from pluto.
Maybe you can try (https://github.com/alibaba/fastjson2)
or extends to rewrite TypeAdapter for Gson
public class MapTypeAdapter extends TypeAdapter {
private final TypeAdapter<Object> delegate = new Gson().getAdapter(Object.class);
@Override
public Object read(JsonReader in) throws IOException {
JsonToken token = in.peek();
switch (token) {
case BEGIN_ARRAY:
List<Object> list = new ArrayList<>();
in.beginArray();
while (in.hasNext()) {
list.add(read(in));
}
in.endArray();
return list;
case BEGIN_OBJECT:
Map<String, Object> map = new LinkedTreeMap<>();
in.beginObject();
while (in.hasNext()) {
map.put(in.nextName(), read(in));
}
in.endObject();
return map;
case STRING:
return in.nextString();
case NUMBER:
double dbNum = in.nextDouble();
if (dbNum > Long.MAX_VALUE) {
return String.valueOf(dbNum);
}
long lngNum = (long) dbNum;
if (dbNum == lngNum) {
return String.valueOf(lngNum);
} else {
return String.valueOf(dbNum);
}
case BOOLEAN:
return in.nextBoolean();
case NULL:
in.nextNull();
return null;
default:
throw new IllegalStateException();
}
}
@Override
public void write(JsonWriter out, Object value) throws IOException {
delegate.write(out,value);
}
}
public T gsonToMap(String strJson) {
Gson gson = new GsonBuilder()
.registerTypeAdapter(new TypeToken(){}.getType(),new MapTypeAdapter()).create();
return gson.fromJson(strJson, new TypeToken() {
}.getType());
}
String json = "{"identifier":"18111111111","opType":1,"platform":0}";
Map<String, Object> map = new MyType<Map<String, Object>>().gsonToMap(json);
from pluto.
sure @ReggieLei,
thanks for the suggestion, will look into this
from pluto.
Related Issues (20)
- ConcurrentModificationException crash HOT 2
- Timber crash due to lambda fun in java HOT 2
- Unable to see Pluto in notifications.
- Not Found import com.pluto.plugin.Plugin in Release HOT 1
- Please add support to Proto DataStore HOT 2
- Crashes detected and show only white page, caused by divider HOT 2
- Unresolved reference error while generating Release universal apk HOT 2
- when I upgrade my compile and target sdk version 32 to 33, It's not working HOT 2
- How can we keep network dataset after app restart? HOT 1
- Problem after adding dependencies for preferences
- Memory Leak: CoordinatorLayout is leaking
- Java.lang.NullPointerException: this.fileName must not be null on 2.1.4
- UninitializedPropertyAccessException - logDao HOT 1
- Pluto Not Initialized HOT 6
- Unresolved Layout files HOT 10
- java.lang.IllegalArgumentException: Cannot serialize Kotlin type HOT 1
- Open pluto in seperate window HOT 1
- Make essential information easier to access, and error notification. HOT 2
- Request Body Shows Wrong Value (Long type) HOT 3
- Content-Type header is null HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pluto.