protected override string RunInBackground(params Stream[] @params) { PublishProgress("Detecting..."); var faceServiceClient = new FaceServiceRestClient(endPoint, key); Com.Microsoft.Projectoxford.Face.Contract.Face[] result = faceServiceClient.Detect(@params[0], true, //FaceId false, // Face LandMarks new FaceServiceClientFaceAttributeType[] { FaceServiceClientFaceAttributeType.Gender, FaceServiceClientFaceAttributeType.Age, FaceServiceClientFaceAttributeType.Smile, FaceServiceClientFaceAttributeType.FacialHair, FaceServiceClientFaceAttributeType.Glasses }); // return Face Attributes : age, gender ..etc if (result == null) { PublishProgress("Detection Finished. Nothing detected"); return(null); } PublishProgress($"Detection Finished. {result.Length} face(s) detected"); Gson gson = new Gson(); var strResult = gson.ToJson(result); Console.WriteLine(strResult + "ABC"); return(strResult); }
private IList <City> loadCities() { // In this case we're loading from local assets. // NOTE: could alternatively easily load from network System.IO.Stream stream; try { stream = Assets.open("cities.json"); } catch (IOException) { return(null); } // GSON can parse the data. // Note there is a bug in GSON 2.3.1 that can cause it to StackOverflow when working with RealmObjects. // To work around this, use the ExclusionStrategy below or downgrade to 1.7.1 // See more here: https://code.google.com/p/google-gson/issues/detail?id=440 Gson gson = (new GsonBuilder()).setExclusionStrategies(new ExclusionStrategyAnonymousInnerClassHelper(this)) .create(); JsonElement json = (new JsonParser()).parse(new System.IO.StreamReader(stream)); IList <City> cities = gson.fromJson(json, (new TypeTokenAnonymousInnerClassHelper(this)).Type); // Open a transaction to store items into the realm // Use copyToRealm() to convert the objects into proper RealmObjects managed by Realm. realm.beginTransaction(); ICollection <City> realmCities = realm.copyToRealm(cities); realm.commitTransaction(); return(new List <City>(realmCities)); }
/// <summary> /// Detecting Face with Cognitive API /// </summary> /// <param name="params"></param> /// <returns></returns> protected override string RunInBackground(params Stream[] @params) { try { faceServiceClient = new FaceServiceRestClient(FaceKey); PublishProgress("잠시만 기다려주세요. 얼굴 인식 중입니다."); //Get Congnitive API result Com.Microsoft.Projectoxford.Face.Contract.Face[] result = faceServiceClient.Detect(@params[0], true, //return FaceId false, new FaceServiceClientFaceAttributeType[] { FaceServiceClientFaceAttributeType.Age, FaceServiceClientFaceAttributeType.Gender , FaceServiceClientFaceAttributeType.FacialHair , FaceServiceClientFaceAttributeType.Smile , FaceServiceClientFaceAttributeType.Glasses , FaceServiceClientFaceAttributeType.HeadPose }); if (result != null) { //parse json to String Gson gson = new Gson(); return(gson.ToJson(result)); } return(null); } catch (System.Exception) { return(null); } }
public List <string> RecognizeText(Stream bitmap) { List <string> list = new List <string>(); try { OCR ocr = visionServiceClient.RecognizeText(bitmap, LanguageCodes.AutoDetect, true); string result = new Gson().ToJson(ocr); OCRModel ocrModel = JsonConvert.DeserializeObject <OCRModel>(result); foreach (var region in ocrModel.regions) { foreach (var line in region.lines) { foreach (var word in line.words) { list.Add(word.text); } } } } catch (Java.Lang.Exception ex) { ex.PrintStackTrace(); string b = ""; } return(list); }
protected override string RunInBackground(params Stream[] @params) { try { PublishProgress("PLEASE WAIT..."); var faceServiceClient = new FaceServiceRestClient("https://westcentralus.api.cognitive.microsoft.com/face/v1.0", "5e729af046e44898beda9b4917f6db8d"); Xamarin.Cognitive.Face.Droid.Contract.Face[] result = faceServiceClient.Detect(@params[0], true, false, null); if (result == null) { PublishProgress("detection failed"); return(null); } PublishProgress("Detection finished" + result.Length + "faces detected"); Gson gson = new Gson(); return(gson.ToJson(result)); } catch (System.Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } finally { _spinner.Dismiss(); } }
private async void btnLogin_Click(object sender, System.EventArgs e) { var result = await Task.Factory.StartNew(DoGet); var txtUsername = FindViewById <EditText>(Resource.Id.txt_login_name); var gson = new Gson(); //gson.FromJson(result, typeof(RespSyncAuthParam)) }
protected override string RunInBackground(params Stream[] @params) { var resultado = mainActivity.ServicioFace.Detect(@params[0], true, false, null); if (resultado == null) { return(null); } Gson gson = new Gson(); var stringresultado = gson.ToJson(resultado); return(stringresultado); }
protected override string RunInBackground(params Stream[] @params) { var result = mainActivity.faceServiceRestClient.Detect(@params[0], true, false, null); if (result == null) { return(null); } Gson gson = new Gson(); var stringResult = gson.ToJson(result); return(stringResult); }
protected override string RunInBackground(params Stream[] @params) { try { PublishProgress("Checking image..."); string[] _cont = { "Adult" }; AnalysisResult _rezultat = _continut._clientVision.AnalyzeImage(@params[0], _cont, null); string _sirRezultat = new Gson().ToJson(_rezultat); return(_sirRezultat); } catch (Java.Lang.Exception) { return(null); } }
protected override string RunInBackground(params string[] @params) { try { UUID uuid = UUID.FromString(@params[0]); var persona = mainActivity.ServicioFace.GetPerson(grupoPersonaId, uuid); Gson gson = new Gson(); var resultado = gson.ToJson(persona); return(resultado); } catch (Exception ex) { return(null); } }
public List <FaceModel> GetSecondFaceId(Stream imageStream) { var faceServiceClient = new FaceServiceRestClient("https://westcentralus.api.cognitive.microsoft.com/face/v1.0", "a7c0326b9c374041808d54073dd15932"); Xamarin.Cognitive.Face.Droid.Contract.Face[] result = faceServiceClient.Detect(imageStream, true, true, null); if (result == null) { return(null); } Gson gson = new Gson(); var json = gson.ToJson(result); FaceObject2 = JsonConvert.DeserializeObject <List <FaceModel> >(json); return(FaceObject2); }
protected internal virtual void onPostExecute(string jsonResponse) { Log.v(outerInstance.TAG, "onPostExecute:"); // Parse the JSON response, get the token and append it to the protected media url. // Then play add the video to the view and play it. Gson gson = new Gson(); ResourceAccessResponse response = gson.fromJson(jsonResponse, typeof(ResourceAccessResponse)); string url = Resources.getString([email protected]_media_url); Uri.Builder builder = Uri.parse(url).buildUpon(); builder.appendQueryParameter("hdnea", response.SecurityToken); url = builder.build().ToString(); brightcoveVideoView.add(Video.createVideo(url)); brightcoveVideoView.start(); }
public void OnSearchResult(Java.Lang.Object results) { TextSearchResponse ResultWrapper = (TextSearchResponse)results; IList <Site> SiteList; if (ResultWrapper == null || ResultWrapper.TotalCount <= 0 || (SiteList = ResultWrapper.Sites) == null || SiteList.Count <= 0) { ResultTextView.Text = "Result is Empty!"; return; } System.Text.StringBuilder ResultText = new System.Text.StringBuilder(); ResultText.AppendLine("Success"); int count = 1; AddressDetail addressDetail; Coordinate location; Poi poi; CoordinateBounds viewport; foreach (Site site in SiteList) { addressDetail = site.Address; location = site.Location; poi = site.Poi; viewport = site.Viewport; string item = "[{0}] siteId: '{1}', name: {2}, formatAddress: {3}, country: {4}, countryCode: {5}, location: {6}, poiTypes: {7}, viewport: {8} "; ResultText.Append(string.Format(item, (count++).ToString(), site.SiteId, site.Name, site.FormatAddress, (addressDetail == null ? "" : addressDetail.Country), (addressDetail == null ? "" : addressDetail.CountryCode), (location == null ? "" : (location.Lat + "," + location.Lng)), (poi == null ? "" : string.Join(",", poi.PoiTypes.ToArray())), (viewport == null ? "" : "northeast{lat=" + viewport.Northeast.Lat + ", lng=" + viewport.Northeast.Lng + "}," + "southwest{lat=" + viewport.Southwest.Lat + ", lng=" + viewport.Southwest.Lng + "}"))); if ((poi != null)) { Gson gson = new Gson(); string jsonString = gson.ToJson(poi.GetChildrenNodes()); ResultText.Append(string.Format("childrenNode: {0} \n\n", jsonString)); } } ResultTextView.Text = ResultText.ToString(); Log.Debug(KeywordSearchActivity.TAG, "OnTextSearchResult: " + ResultText.ToString()); }
protected override string RunInBackground(params Stream[] @params) { try { PublishProgress("Recognizing..."); string[] features = { "Description" }; string[] details = { }; AnalysisResult result = detectDescriptionActivity.visionServices.AnalyzeImage(@params[0], features, details); string stresult = new Gson().ToJson(result); return(stresult); } catch (Java.Lang.Exception ex) { return(null); } }
protected override string RunInBackground(params string[] @params) { try { UUID uuid = UUID.FromString(@params[0]); var person = mainActivity.faceServiceRestClient.GetPerson(personGroupId, uuid); Gson gson = new Gson(); var result = gson.ToJson(person); return(result); } catch (Exception ex) { return(null); System.Console.WriteLine("PersonDetectionTask exception has thrown."); } }
/// <summary> /// Vision Detection Function /// </summary> /// <param name="params"></param> /// <returns></returns> protected override string RunInBackground(params Stream[] @params) { try { PublishProgress("상황 인식 중.."); string[] features = { "Description" }; string[] details = { }; AnalysisResult result = VisionServiceRestClient.AnalyzeImage(@params[0], features, details); if (result != null) { string strResult = new Gson().ToJson(result); return(strResult); } return(null); } catch (Exception ex) { return(null); } }
protected override string RunInBackground(params string[] @params) { try { UUID[] listaUuid = new UUID[(@params.Length)]; for (int i = 0; i < @params.Length; i++) { listaUuid[i] = UUID.FromString(@params[i]); } var resultado = mainActivity.ServicioFace.Identity(grupoPersonaId, listaUuid, 1); Gson gson = new Gson(); var resultadoString = gson.ToJson(resultado); return(resultadoString); } catch (Exception ex) { return(null); } }
public void OnSearchResult(Java.Lang.Object resultObject) { DetailSearchResponse detailSearchResponse = (DetailSearchResponse)resultObject; StringBuilder resultText = new StringBuilder(); Site site = detailSearchResponse.Site; if (site == null) { ResultTextView.Text = "Result is Empty!"; return; } System.Text.StringBuilder ResultText = new System.Text.StringBuilder(); ResultText.AppendLine("Success"); AddressDetail addressDetail = site.Address; Coordinate location = site.Location; Poi poi = site.Poi; CoordinateBounds viewport = site.Viewport; string item = "siteId: '{0}', name: {1}, formatAddress: {2}, country: {3}, countryCode: {4}, location: {5}, poiTypes: {6}, viewport: {7} "; ResultText.Append(string.Format(item, site.SiteId, site.Name, site.FormatAddress, (addressDetail == null ? "" : addressDetail.Country), (addressDetail == null ? "" : addressDetail.CountryCode), (location == null ? "" : (location.Lat + "," + location.Lng)), (poi == null ? "" : string.Join(",", poi.PoiTypes.ToArray())), (viewport == null ? "" : "northeast{lat=" + viewport.Northeast.Lat + ", lng=" + viewport.Northeast.Lng + "}," + "southwest{lat=" + viewport.Southwest.Lat + ", lng=" + viewport.Southwest.Lng + "}"))); if ((poi != null)) { Gson gson = new Gson(); string jsonString = gson.ToJson(poi.GetChildrenNodes()); ResultText.Append(string.Format("childrenNode: {0} \n\n", jsonString)); } ResultTextView.Text = ResultText.ToString(); Log.Debug(KeywordSearchActivity.TAG, "OnDetailSearchResult: " + ResultText.ToString()); }
public List <FaceModel> GetFirstFaceId(Stream imageStream) { try { var faceServiceClient = new FaceServiceRestClient("https://westcentralus.api.cognitive.microsoft.com/face/v1.0", "a7c0326b9c374041808d54073dd15932"); Xamarin.Cognitive.Face.Droid.Contract.Face[] result = faceServiceClient.Detect(imageStream, true, true, null); if (result == null) { return(null); } Gson gson = new Gson(); var json = gson.ToJson(result); FaceObject1 = JsonConvert.DeserializeObject <List <FaceModel> >(json); return(FaceObject1); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } }
protected override string RunInBackground(params string[] @params) { try { UUID[] uuidList = new UUID[@params.Length]; for (int i = 0; i < @params.Length; i++) { uuidList[i] = UUID.FromString(@params[i]); } var result = mainActivity.faceServiceRestClient.Identity(personGroupId , uuidList , 1); Gson gson = new Gson(); var resultString = gson.ToJson(result); return(resultString); } catch (System.Exception) { return(null); } }
protected internal virtual void onPostExecute(string jsonResponse) { Log.v(outerInstance.TAG, "onPostExecute:"); // Parse the JSON response, get the first IDP and pass it to the webview activity // to load the login page. IList <string> idps = new List <string>(); Gson gson = new Gson(); ChooserResponse response = gson.fromJson(jsonResponse, typeof(ChooserResponse)); IEnumerator it = response.PossibleIdps.SetOfKeyValuePairs().GetEnumerator(); while (it.hasNext()) { DictionaryEntry pairs = (DictionaryEntry)it.next(); idps.Add(pairs.Key.ToString()); it.remove(); } Intent intent = new Intent(outerInstance, typeof(WebViewActivity)); intent.putExtra(AIS_TARGET_URL, outerInstance.initUrl + idps[0]); startActivityForResult(intent, WEBVIEW_ACTIVITY); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.carritolayout); Xamarin.Essentials.Platform.Init(this, savedInstanceState); changelugarentrega = FindViewById <Button>(Resource.Id.changelugarentrega); lugarentrega = FindViewById <TextView>(Resource.Id.lugarentrega); metododepagobtn = FindViewById <Button>(Resource.Id.metodopagobtn); promocionbtn = FindViewById <Button>(Resource.Id.promocionbtn); var productoscarrito = FindViewById <ListView>(Resource.Id.productoscarrito); propinabtn = FindViewById <Button>(Resource.Id.propinabtn); metodopago = FindViewById <TextView>(Resource.Id.metodopago); propina = FindViewById <TextView>(Resource.Id.propina); promocion = FindViewById <TextView>(Resource.Id.promocion); costoproductos = FindViewById <TextView>(Resource.Id.costoproductos); propinaagregada = FindViewById <TextView>(Resource.Id.propinagregada); costodeservicio = FindViewById <TextView>(Resource.Id.costoservicio); promocionagregada = FindViewById <TextView>(Resource.Id.promocionagregada); totalapagar = FindViewById <TextView>(Resource.Id.totalpagar); finalizarpedido = FindViewById <Button>(Resource.Id.finalizarpedidobtn); ISharedPreferences preff = PreferenceManager.GetDefaultSharedPreferences(this); String json = preff.GetString("MyObject", ""); Gson gson = new Gson(); productos = JsonConvert.DeserializeObject <List <Pedidoadap> >(json); productoscarrito.Adapter = new Carritolistproductosadapter(this, productos); GetLocationAsync(); changelugarentrega.Click += Changelugarentrega_Click; float suma = productos.Sum(productos => productos.PrecioProducto); costoproductos.Text = "$" + suma.ToString() + ".00"; AddData(suma); finalizarpedido.Click += Finalizarpedido_Click1; }
private DefaultFieldTypesLocalJsonSource(Resources resources, Gson gson) { mResources = resources; mGson = gson; }
public void OnSearchResult(Java.Lang.Object results) { QueryAutocompleteResponse ResultWrapper = (QueryAutocompleteResponse)results; if (ResultWrapper == null) { ResultTextView.Text = "Result is Empty!"; return; } System.Text.StringBuilder ResultText = new System.Text.StringBuilder(); IList <Site> SiteList; IList <AutoCompletePrediction> predictions; predictions = ResultWrapper.Predictions; if (predictions != null && predictions.Count > 0) { ResultText.Append("AutoCompletePrediction[ ]:\n"); int PredictionCount = 1; foreach (AutoCompletePrediction mPrediction in predictions) { ResultText.Append(string.Format("[{0}] Prediction, description = {1} ,", "" + (PredictionCount++), mPrediction.Description)); Word[] matchedKeywords = mPrediction.GetMatchedKeywords(); foreach (Word matchedKeyword in matchedKeywords) { ResultText.Append("matchedKeywords: " + matchedKeyword.ToString()); } Word[] matchedWords = mPrediction.GetMatchedWords(); foreach (Word matchedWord in matchedWords) { ResultText.Append(",matchedWords: " + matchedWord.ToString()); } ResultText.Append("\n"); } } else { ResultText.Append("Predictions 0 results"); } ResultText.Append("\n\nSite[ ]:\n"); SiteList = ResultWrapper.Sites; if (SiteList != null && SiteList.Count > 0) { int SiteCount = 1; AddressDetail addressDetail; Coordinate location; Poi poi; CoordinateBounds viewport; foreach (Site site in SiteList) { addressDetail = site.Address; location = site.Location; poi = site.Poi; viewport = site.Viewport; string item = "[{0}] siteId: '{1}', name: {2}, formatAddress: {3}, utcOffset: {4}, country: {5}, countryCode: {6}, location: {7}, distance: {8}, poiTypes: {9}, viewport: {10}, streetNumber: {11}, postalCode: {12} , tertiaryAdminArea: {13}, "; ResultText.Append(string.Format(item, (SiteCount++).ToString(), site.SiteId, site.Name, site.FormatAddress, site.UtcOffset, (addressDetail == null ? "" : addressDetail.Country), (addressDetail == null ? "" : addressDetail.CountryCode), (location == null ? "" : (location.Lat + "," + location.Lng)), site.Distance, (poi == null ? "" : string.Join(",", poi.PoiTypes.ToArray())), (viewport == null ? "" : "northeast{lat=" + viewport.Northeast.Lat + ", lng=" + viewport.Northeast.Lng + "}," + "southwest{lat=" + viewport.Southwest.Lat + ", lng=" + viewport.Southwest.Lng + "}"), (addressDetail == null ? "" : addressDetail.StreetNumber), (addressDetail == null ? "" : addressDetail.PostalCode), (addressDetail == null ? "" : addressDetail.TertiaryAdminArea))); if ((poi != null)) { Gson gson = new Gson(); string jsonString = gson.ToJson(poi.GetChildrenNodes()); ResultText.Append(string.Format("childrenNode: {0} \n\n", jsonString)); } } } else { ResultText.Append("sites 0 results\n"); } ResultTextView.Text = ResultText.ToString(); Log.Debug(QueryAutoCompleteActivity.TAG, "OnAutoCompleteResult: " + ResultText.ToString()); }
private async void Analyze() { // Get bitmap. Bitmap bitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.form_recognition); // Convert bitmap to MLFrame. MLFrame frame = MLFrame.FromBitmap(bitmap); // Create analyzer. MLFormRecognitionAnalyzer analyzer = MLFormRecognitionAnalyzerFactory.Instance.FormRecognitionAnalyzer; Task <JsonObject> task = analyzer.AnalyseFrameAsync(frame); try { await task; if (task.IsCompleted && task.Result != null) { //Recognition success JsonObject jsonObject = task.Result; if (jsonObject.Get("retCode").AsInt == MLFormRecognitionConstant.Success) { string str = jsonObject.ToString(); form_result.Text = str; try { Gson gson = new Gson(); MLFormRecognitionTablesAttribute attribute = (MLFormRecognitionTablesAttribute)gson.FromJson(str, Java.Lang.Class.FromType(typeof(MLFormRecognitionTablesAttribute))); Log.Debug(Tag, "RetCode: " + attribute.RetCode); MLFormRecognitionTablesAttribute.TablesContent tablesContent = attribute.GetTablesContent(); Log.Debug(Tag, "tableCount: " + tablesContent.TableCount); IList <MLFormRecognitionTablesAttribute.TablesContent.TableAttribute> tableAttributeArrayList = tablesContent.TableAttributes; Log.Debug(Tag, "tableID: " + tableAttributeArrayList.ElementAt(0).Id); IList <MLFormRecognitionTablesAttribute.TablesContent.TableAttribute.TableCellAttribute> tableCellAttributes = tableAttributeArrayList.ElementAt(0).TableCellAttributes; for (int i = 0; i < tableCellAttributes.Count; i++) { Log.Debug(Tag, "startRow: " + tableCellAttributes.ElementAt(i).StartRow); Log.Debug(Tag, "endRow: " + tableCellAttributes.ElementAt(i).EndRow); Log.Debug(Tag, "startCol: " + tableCellAttributes.ElementAt(i).StartCol); Log.Debug(Tag, "endCol: " + tableCellAttributes.ElementAt(i).EndCol); Log.Debug(Tag, "textInfo: " + tableCellAttributes.ElementAt(i).TextInfo); Log.Debug(Tag, "cellCoordinate: "); MLFormRecognitionTablesAttribute.TablesContent.TableAttribute.TableCellAttribute.TableCellCoordinateAttribute coordinateAttribute = tableCellAttributes.ElementAt(i).GetTableCellCoordinateAttribute(); Log.Debug(Tag, "topLeft_x: " + coordinateAttribute.TopLeftX); Log.Debug(Tag, "topLeft_y: " + coordinateAttribute.TopLeftY); Log.Debug(Tag, "topRight_x: " + coordinateAttribute.TopRightX); Log.Debug(Tag, "topRight_y: " + coordinateAttribute.TopRightY); Log.Debug(Tag, "bottomLeft_x: " + coordinateAttribute.BottomLeftX); Log.Debug(Tag, "bottomLeft_y: " + coordinateAttribute.BottomLeftY); Log.Debug(Tag, "bottomRight_x: " + coordinateAttribute.BottomRightX); Log.Debug(Tag, "bottomRight_y: " + coordinateAttribute.BottomRightY); } } catch (Exception e) { Log.Error(Tag, e.Message); } } } else { //Recognition failed Log.Debug(Tag, "Recognition Failed"); } } catch (Exception ex) { //Operation failed Log.Error(Tag, ex.Message); } }
public static DefaultFieldTypesLocalJsonSource GetInstance(Resources resources, Gson gson) { if (sInstance == null) { sInstance = new DefaultFieldTypesLocalJsonSource(resources, gson); } return(sInstance); }
public void EntityPlayerDatasToSave(EntityPlayer player) { PlayerDatas entityDatasToSave = new PlayerDatas(); // Datas for identifying the player entityDatasToSave.setplayerDataToSaveName(player.getEntityName()); entityDatasToSave.setplayerDataToSaveClass(player.getEntityClass()); entityDatasToSave.setplayerDataToSaveRace(player.getEntityRace()); entityDatasToSave.setplayerDataToSavePortrait(player.getEntityPortrait()); entityDatasToSave.setplayerDataToSaveLevel(player.getEntityLevel()); // Datas for checking if the player is drunk or not entityDatasToSave.setplayerDataToSaveAlcoholLevel(player.getEntityAlcoholLevel()); entityDatasToSave.setplayerDataToSaveAlcoholResistance(player.getEntityAlcoholResistance()); // Datas for positionning the player in the game world entityDatasToSave.setplayerDataToSaveMap(player.getEntityMap()); entityDatasToSave.setplayerDataToSaveXPosition(player.getEntityXPosition()); entityDatasToSave.setplayerDataToSaveYPosition(player.getEntityYPosition()); // Datas for battle entityDatasToSave.setplayerDataToSaveAttack(player.getEntityAttack()); entityDatasToSave.setplayerDataToSaveDefense(player.getEntityDefense()); entityDatasToSave.setplayerDataToSaveCurrentHealth(player.getEntityCurrentHealth()); entityDatasToSave.setplayerDataToSaveTotalHealth(player.getEntityTotalHealth()); // Datas for experience status entityDatasToSave.setplayerDataToSaveCurrentXp(player.getEntityCurrentXp()); entityDatasToSave.setplayerDataToSaveTotalXp(player.getEntityTotalXp()); entityDatasToSave.setplayerDataToSaveGold(player.getEntityGold()); // Data to get the player state (Drunk, sleeping...) entityDatasToSave.setplayerDataToSaveState(player.getEntityState()); // -------------------------------------------------------------- // | The method in comment below will only save non empty datas | // -------------------------------------------------------------- // [START] //Gson gson = new GsonBuilder().setPrettyPrinting().create(); //String jsonToSave = json.prettyPrint(entityDatasToSave); // [END] // ---------------------------------------------------------------------------------------- // | The method in comment below will save all datas from a character even the empty ones | // ---------------------------------------------------------------------------------------- // [START] Gson gson = new Gson(); String jsonToSave = gson.toJson(entityDatasToSave); // [END] Json json = new Json(); json.setOutputType(OutputType.json); // saving datas in a new JSON file with the name of the player character try { SaveGame.saveFile(entityDatasToSave.getplayerDataToSaveName(), jsonToSave, "character"); } catch (IOException e) { Console.WriteLine("Error: error when creating character file"); e.printStackTrace(); } }