Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6924057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:36:54+00:00 2026-05-27T10:36:54+00:00

I have a REST-service that returns JSON. But the JSON response returned with \

  • 0

I have a REST-service that returns JSON. But the JSON response returned with \ before quotes (escape character)….I need those escapre slashes removed!

This is an example response to show what is happening:

“[{\”Id\”:\”0\”,\”FirstName\”:\”0firstname\”,\”LastName\”:\”0 lastname\”},{\”Id\”:\”1\”,\”FirstName\”:\”1firstname\”,\”LastName\”:\”1 lastname\”},{\”Id\”:\”2\”,\”FirstName\”:\”2firstname\”,\”LastName\”:\”2 lastname\”},{\”Id\”:\”3\”,\”FirstName\”:\”3firstname\”,\”LastName\”:\”3 lastname\”},{\”Id\”:\”4\”,\”FirstName\”:\”4firstname\”,\”LastName\”:\”4 lastname\”},{\”Id\”:\”5\”,\”FirstName\”:\”5firstname\”,\”LastName\”:\”5 lastname\”},{\”Id\”:\”6\”,\”FirstName\”:\”6firstname\”,\”LastName\”:\”6 lastname\”},{\”Id\”:\”7\”,\”FirstName\”:\”7firstname\”,\”LastName\”:\”7 lastname\”},{\”Id\”:\”8\”,\”FirstName\”:\”8firstname\”,\”LastName\”:\”8 lastname\”},{\”Id\”:\”9\”,\”FirstName\”:\”9firstname\”,\”LastName\”:\”9 lastname\”},{\”Id\”:\”10\”,\”FirstName\”:\”10firstname\”,\”LastName\”:\”10 lastname\”}]”

The JSON is parsed by Layar (http://layar.pbworks.com/w/page/28473583/GetPOIs-Request%20and%20Response%20Examples), so I cant influence the parsing and they dont allow these escape characters.

Here’s my code:

**RestServiceImpl.vb

Imports System.ServiceModel
Imports System.ServiceModel.Web
Imports System.IO
Imports System.ServiceModel.Activation
Imports System.Web.Script.Serialization
Imports System.Collections.Generic

Namespace RestService

Public Class Employee
    Public Property Id() As String
        Get
            Return m_Id
        End Get
        Set(value As String)
            m_Id = Value
        End Set
    End Property
    Private m_Id As String
    Public Property FirstName() As String
        Get
            Return m_FirstName
        End Get
        Set(value As String)
            m_FirstName = Value
        End Set
    End Property
    Private m_FirstName As String
    Public Property LastName() As String
        Get
            Return m_LastName
        End Get
        Set(value As String)
            m_LastName = Value
        End Set
    End Property
    Private m_LastName As String
End Class

<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class RestServiceImpl
    Implements IRestServiceImpl

    Public Function XMLData(ByVal id As String) As String _
        Implements IRestServiceImpl.XMLData

        Return "XML You requested product " & id

    End Function

    Public Function JSONData(ByVal lat As String, ByVal lng As String, ByVal d As String, ByVal cat As String) As String _
        Implements IRestServiceImpl.JSONData

        Dim json As New JavaScriptSerializer()
        Dim l As New List(Of Employee)

        Dim e As Employee
        For i As Integer = 0 To 10
            e = New Employee
            e.Id = i.ToString
            e.FirstName = i.ToString + "firstname"
            e.LastName = i.ToString + " lastname"
            l.Add(e)
        Next i

        Dim jsonMessage As String = json.Serialize(l.ToArray())
        Return jsonMessage

    End Function

End Class



End Namespace

**IRestServiceImpl.vb

Imports System.ServiceModel
Imports System.ServiceModel.Web
Imports System.IO
Imports System.ServiceModel.Activation

Namespace RestService
' NOTE: You can use the "Rename" command on the context menu to change the interface name "IRestServiceImpl" in both code and config file together.
<ServiceContract()> _
Public Interface IRestServiceImpl
    <OperationContract()> _
    <WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Xml, BodyStyle:=WebMessageBodyStyle.Wrapped, UriTemplate:="xml/{id}")> _
    Function XMLData(ByVal id As String) As String


    'WebMessageBodyStyle.Bare WAS WebMessageBodyStyle.wrapped
    <OperationContract()> _
    <WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Bare, UriTemplate:="api/objects/json/?lat={lat}&lon={lon}&radius={radius}&cat={cat}")> _
    Function JSONData(ByVal lat As String, ByVal lon As String, ByVal radius As String, ByVal cat As String) As String
    'radius in meters
End Interface


Public Class RawService
    <OperationContract(), WebGet()> _
    Public Function GetValue() As System.IO.Stream
        Dim result As String = "Hello world"
        Dim resultBytes As Byte() = Encoding.UTF8.GetBytes(result)
        WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain"
        Return New MemoryStream(resultBytes)
    End Function

End Class

End Namespace
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:36:54+00:00Added an answer on May 27, 2026 at 10:36 am

    Turns out it’s BAD to manually serialize json like this: json.Serialize(l.ToArray()). I was reading this here: http://encosia.com/asp-net-web-services-mistake-manual-json-serialization/
    So, what I did is just return the list of employees and now its all good!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a WCF REST service that returns JSON, but the properties in
I have a REST service that returns a list of objects. Each object contains
I have a REST web service that returns an xml result like this: -
I have a web service class that the rest of the framework depends on
am new to Json so a little green. I have a Rest Based Service
I have a WCF service method that returns a big byte[] array around 2
I have written a WCF service with the REST template that has the defaultOutgoingResponseFormat
I have successfully set up a quick test of creating a REST-like service that
I have a WCF REST service that exposes a couple dozen objects and based
I have a REST web-service interface that calls-down to a service layer which orchestrates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.