Repository: serde-rs/json (language: rust)

Issue:
u128 doesn't work for Value
Looks like there's a bug in serde_json. This program:

```
#[macro_use]
extern crate serde_json;
use std::str::FromStr;

fn main() {
    let string = format!("{}", u128::max_value());
    println!("{}", string);
    let val = serde_json::value::Value::from_str(&string);
    let val2 = serde_json::to_value(u128::max_value());
    println!("{:#?}, {:#?}", val, val2);
}
```

outputs:

```
340282366920938463463374607431768211455
Ok(
    Number(
        340282366920938500000000000000000000000.0
    )
), Err(
    Error("u128 is not supported", line: 0, column: 0)
)
```

[playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=4b3d4b4c201c7a8dc5d3e4f93c1f8bae)

if you put arbitrary_precision feature, then Value works 100% without cutting precision, if you do it via `u128` => `String` => `Value`. However direct conversion `u128` => `Value` with `to_value` results in error.


Discussion / hints:
Thanks! I would accept a PR to support u128 => Value in the case that arbitrary_precision is enabled.

Fix patch:
diff --git a/src/value/ser.rs b/src/value/ser.rs
index 172784cce..c377b533d 100644
--- a/src/value/ser.rs
+++ b/src/value/ser.rs
@@ -77,6 +77,13 @@ impl serde::Serializer for Serializer {
         Ok(Value::Number(value.into()))
     }
 
+    serde_if_integer128! {
+        #[cfg(feature = "arbitrary_precision")]
+        fn serialize_i128(self, value: i128) -> Result<Value, Error> {
+            Ok(Value::Number(Number::from_string_unchecked(value.to_string())))
+        }
+    }
+
     #[inline]
     fn serialize_u8(self, value: u8) -> Result<Value, Error> {
         self.serialize_u64(value as u64)
@@ -97,6 +104,13 @@ impl serde::Serializer for Serializer {
         Ok(Value::Number(value.into()))
     }
 
+    serde_if_integer128! {
+        #[cfg(feature = "arbitrary_precision")]
+        fn serialize_u128(self, value: u128) -> Result<Value, Error> {
+            Ok(Value::Number(Number::from_string_unchecked(value.to_string())))
+        }
+    }
+
     #[inline]
     fn serialize_f32(self, value: f32) -> Result<Value, Error> {
         self.serialize_f64(value as f64)


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 97da8133a..c08645a02 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -1909,6 +1909,13 @@ fn test_partialeq_number() {
     );
 }
 
+#[test]
+#[cfg(integer128)]
+#[cfg(feature = "arbitrary_precision")]
+fn test_partialeq_integer128() {
+    number_partialeq_ok!(i128::MIN i128::MAX u128::MIN u128::MAX)
+}
+
 #[test]
 fn test_partialeq_string() {
     let v = to_value("42").unwrap();