Json String To Byte Array : Json « Network « C# / C Sharp






Json String To Byte Array

 

using System;
using System.IO;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Imaging;

public static class Tool
{


    public static byte[] JsonStringToByteArray(string jsonByteString)
    {
        jsonByteString = jsonByteString.Substring(1, jsonByteString.Length - 2);
        string[] arr = jsonByteString.Split(',');
        byte[] bResult = new byte[arr.Length];
        for (int i = 0; i < arr.Length; i++)
        {
            bResult[i] = byte.Parse(arr[i]);
        }
        return bResult;
    }


}

   
  








Related examples in the same category

1.JSON (JavaScript Object Notation) Utility Methods.
2.DataContractJsonSerializer Demo
3.Creates a JSON graph of all of the field's client-side data
4.Serializes/Deserializes source into a JSON string.
5.Removes Json null objects from the serialized string and return a new string(Extention Method)