  | 
              
	              
	                
  
    |   | 
   
  
    
        
        ทำไม unicode แปลงกลับเป็นอักษรไทยไม่ได้ เวลา return json ทั้งๆๆที่ set เป็น toString งง ปวดหัวมากเลย     | 
   
  
    |   | 
   
 
 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ถ้าข้อความต้นฉบับถูกเข้ารหัสและส่งมาเป็นแบบ UTF-8 ก่อน มันจะไสามารถ Encode/Decode ได้ไม่มีปัญหาครับ                          
               
               | 
             
            
              
			  			  
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2016-01-05 17:18:18 | 
                        By :
                            mr.win | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 งง ไม่เข้าใจ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2016-01-06 08:39:40 | 
                        By :
                            paravatee | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ไม่รู้ว่าทำได้หรือยังนะครับ ถ้ายังก็ลองทำตามวิธีนี้นะครับ ผมลองแล้วได้ (ผมถามอาจารย์ goo) 
 
  
 
Code (C#) 
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Windows.Forms;
namespace SampleGetJson
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {           
            string json = get_web_content(url);
            dynamic array = JsonConvert.DeserializeObject(json);      
            foreach (var item in array)
            {
                docIsoList.Add(new DocIso { Id = item["Id"]
                    ,DocNum = item["doc_num"]
                ,DocDate = item["doc_date"]
                ,DocType = item["doc_type"]
                ,CustName = item["cust_name"]
                ,Nonconformity = item["nonconformity"]
                ,Job = item["job"]});
            }
            this.dataGridView1.DataSource = docIsoList;
        }
        private string url = "http://localhost/aut_datacenter/adminapi/docs";
        private List<DocIso> docIsoList = new List<DocIso>();      
        public string  get_web_content(string url)
        {
            Uri uri = new Uri(url);
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
            request.Method = WebRequestMethods.Http.Get;
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            string output = reader.ReadToEnd();
            response.Close();
            return output;
        }
    }
    public class DocIso
    {        
        public String Id { get; set; }       
        public String DocNum { get; set; }       
        public String DocDate { get; set; }       
        public String DocType { get; set; }      
        public String Nonconformity { get; set; }       
        public String CustName { get; set; }      
        public String Job { get; set; }
    }
}
 
 
ดัดแปลงมาจาก 
http://4rapiddev.com/csharp/c-read-json-from-url-and-parsedeserialize-json/ 
 
ได้บ่ได้จังได๋กะบอกกันแน่เด้อ พี่น้อง                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2016-01-06 10:56:34 | 
                        By :
                            บัญดิษฐ | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 String a =System.Text.RegularExpressions.Regex.Unescape(JJ.querykey("3", "kk").Replace(" ", "").ToString());  
MessageBox.Show(a);   
 
 
ใช้แบบนี้ครับ ผมว่าตอนมัน retrun ค่ามาจาก json บนเว็บ เหมือนมันติดค่า escapse sequense ต้องใช้คำสั่ง Unescape แล้วมันก็แปลงเป็นภาษาไทยให้เลย แบบนี้ จะได้คำตอบเป็น "มหาวิทครับ "                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2016-01-06 11:52:49 | 
                        By :
                            paravatee | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |