Advertisement
halleman19

array to json | c#/unity3d

Jan 19th, 2025 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | Software | 0 0
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3.  
  4. public class Utils
  5. {
  6.     public static string arrayToJson<T>(IList<T> array, char separate)
  7.     {
  8.         string response = string.Empty;
  9.  
  10.         for (int i = 0; i < array.Count; i++)
  11.         {
  12.             response += JsonUtility.ToJson(array[i]);
  13.  
  14.             if (i != array.Count - 1)
  15.                 response += separate;
  16.         }
  17.  
  18.         return response;
  19.     }
  20. }
  21.  
  22. // example: https://www.youtube.com/watch?v=new5vnMsbwI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement