Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I have a created a webService, whose output string (in JSON) is given below :
 
"[{\"CALC_ALTITUDE\":213,\u000a\"ZA_MAINS_SUPPLY\":\"3~ 400V 50Hz\"}]"
 
When i set this string in a TextBox, the output comes like this :
 
[{
"CALC_ALTITUDE":213,
"ZA_MAINS_SUPPLY":"3~ 400V 50Hz"
}]

 
And this is a proper JSON text.
 
But, when i access this using REST Console, the output appears like :
 
"[{\"CALC_ALTITUDE\":213,\u000a\"ZA_MAINS_SUPPLY\":\"3~ 400V 50Hz\"}]"
 
My problem is that, TextBox is interpreting this text very well, by reading newline characters and escape sequence \". But, REST Console is not able to do so.
 
Any idea how to show this text in the same way as this
[{
"CALC_ALTITUDE":213,
"ZA_MAINS_SUPPLY":"3~ 400V 50Hz"
}]

 
in REST console as well ??
 
Thanks
Posted 3-Jun-13 20:59pm
Comments
Jameel Moideen at 4-Jun-13 2:23am
   
can you post the rest endpoint?
Jameel Moideen at 4-Jun-13 2:26am
   
also post the code for calling the rest service in console
amitt0488 at 4-Jun-13 2:54am
   
[DllImport("FANselect.dll", CallingConvention = CallingConvention.StdCall,
EntryPoint = "ZAJsonRequestA", ExactSpelling = false)]
private static extern IntPtr ZAJsonRequestA([MarshalAs(UnmanagedType.LPStr)]StringBuilder szReq);
 
public string getZAJsonRequestA(string input)
{
StringBuilder sbuilder = new StringBuilder();
sbuilder.Append(input);
var variable = ZAJsonRequestA(sbuilder);
string sResult = Marshal.PtrToStringAnsi(variable);
string op = sResult.Trim();

return op;
}
 
Here the output is coming from a DLL and getZAJsonRequestA(input) is called using a url which interacts with the DLL & gives the output in string form.
 
This output is shown in REST Console.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,382


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 4 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100