This repository was archived by the owner on Mar 1, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
src/main/java/com/smoothnlp/nlp/basic Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 4545 <version >0.82</version >
4646 </dependency >
4747
48+ <dependency >
49+ <groupId >com.google.code.gson</groupId >
50+ <artifactId >gson</artifactId >
51+ <version >2.8.5</version >
52+ </dependency >
4853
4954 </dependencies >
5055
Original file line number Diff line number Diff line change 2929 <orderEntry type =" library" name =" Maven: ml.dmlc:xgboost4j:0.82" level =" project" />
3030 <orderEntry type =" library" name =" Maven: com.typesafe.akka:akka-actor_2.11:2.3.11" level =" project" />
3131 <orderEntry type =" library" name =" Maven: com.typesafe:config:1.2.1" level =" project" />
32+ <orderEntry type =" library" name =" Maven: com.google.code.gson:gson:2.8.5" level =" project" />
3233 </component >
3334</module >
Original file line number Diff line number Diff line change 11package com .smoothnlp .nlp .basic ;
22
33import java .util .Arrays ;
4+ import com .google .gson .Gson ;
5+ import com .google .gson .GsonBuilder ;
46
57public class UtilFns {
68
@@ -41,4 +43,13 @@ public static float[] flatten2dFloatArray(float[][] f2darray){
4143 return output ;
4244 }
4345
46+
47+ public static String toJson (Object o ){
48+ GsonBuilder gb = new GsonBuilder ();
49+ gb = gb .serializeSpecialFloatingPointValues ();
50+ gb = gb .serializeNulls ();
51+ Gson gson = gb .create ();
52+ return gson .toJson (o );
53+ }
54+
4455}
You can’t perform that action at this time.
0 commit comments