title: Returning a byte[] representing an image as JSON?
body: <p>I am creating an object server-side which is to have all of the data necessary to represent the object client-side. One of the properties I would like my client-object to have is the its icon.</p>
  
  <p>Currently, I have the following code. It hasn't been ran yet, I just wanted to discuss some things with S.O:</p>
  
  <pre><code>public class ComponentDiagramPolygonChild
  {
      IconServicesSoapClient IconServicesProxy = new IconServicesSoapClient("IconServicesSoap");
  
      public string Name { get; set; }
      public byte[] Icon { get; set; }
  
      public ComponentDiagramPolygonChild(PlanViewComponent planViewComponent)
      {
          Name = planViewComponent.Name;
          //TODO: Can icon ever return null here?
          Icon = IconServicesProxy.GetIconByID(planViewComponent.Icon).Image;
          planViewComponent.
      }
  }
  </code></pre>
  
  <p>It seems to me that I have two options available:</p>
  
  <ul>
  <li>Store the ID of the Icon as the property instead of byte[].</li>
  <li>Store the Icon as a byte[].</li>
  </ul>
  
  <p>If I use the former suggestion I will need to go out to the server and request the image data by passing to the server the icon's ID. I believe this would be a more simplistic approach -- I would just return a memory stream housing the image and load that stream in the desired location. The negative aspect of this is multiple hits on the server which seem to be completely unnecessary.</p>
  
  <p>If I use the latter suggestion I will be passing a (significantly?) larger amount of data across the network. I am unsure if byte arrays are able to be JSONized properly. I am unsure of how to take a jsonized byte[] and convert it into image data.</p>
  
  <p>Does anyone have any experience with this situation? How should I tackle this? Thanks.</p>
  
  <p>EDIT: After doing some reading it looks like the former option is my best bet.</p>