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 6983249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:23:40+00:00 2026-05-27T18:23:40+00:00

I am trying to convert an existing .Net shop site to an Android app.

  • 0

I am trying to convert an existing .Net shop site to an Android app.

(This is in VB)

One of the main objects holds product data.

Within that object there is, for instance:

<H2>Product Title</H2>
<P>A description</P>

I have already built a WCF Rest service which returns the data I expect:…

Having said that, I have trialled Newtonsoft.Json and DataContractJsonSerializer which produce the same, but different, outputs.

When running the WCF service in debug using Newtonsoft.Json it returns those items as I would expect:

Newtonsoft:

<H2>Product Title<\/H2><P>A description<\/P>

DataContractJsonSerializer:

<H2>Product Title<\\\/H2><P>A description<\\\/P>

However, when I run the Android app through Eclipse I get the error of “Invalid escape sequence (valid ones are \b \t \n \f \r \” \’ \ )”

So, in short; how to stop Newtonsoft or DataContractJsonSerializer from inserting these escape sequences?

Thanks
Dave

UPDATE:

I have tracked this down to something (?) that WCF is doing. Here is the final bit of my code which returns the JSON string:

retVal = CacheManager.JSONFullProduct("P" & ProductID)

At this point ‘retVal’ is storing closing HTML tags with just ‘/’

retVal = retVal.Replace("\/", "/")

At this point ‘retVal’ is still storing closing HTML tags with just ‘/’

Return retVal

At this point ‘retVal’ itself is still storing closing HTML tags with just ‘/’, but when it actually returns (either to Notepad if I’m running the Service direct, or to Android) ‘/’ suddenly becomes ‘{backslash}/’

I’ve tried to do a string replace in the android app:

result.replace("\/", "/");

But that returns the same error of “Invalid escape sequence…”, and anyway, I don’t really want to be doing this kind of work on the phone.

So, what is happening at Return retVal to suddenly insert all of these escape characters??

  • 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-27T18:23:41+00:00Added an answer on May 27, 2026 at 6:23 pm

    I have searched high and wide for an answer to this, and have finally found it.

    I will share for anyone else experiencing the same issue:

    It is the WCF Rest service.

    Learning WCF and Android at the same time led me to believe that the response from WCF should be a String serialized in the Json format.

    To do this, a .Net object, array or whatever would go through DataContractJsonSerializer before being returned as a String to Android for further parsing.

    Something like this:

    Dim stream1 As MemoryStream = New MemoryStream
    Dim ser As DataContractJsonSerializer = New DataContractJsonSerializer(GetType(myType))
    ser.WriteObject(stream1, myThing)
    Dim _json As String = Encoding.UTF8.GetString(stream1.ToArray())
    stream1.Close()
    return _json
    

    Wrong.

    Keep your object, array or whatever and return that instead; WCF will take care of the proper escaping for you.

    For example (this is VB);

    IService:

    <OperationContract()> _
    <WebGet(BodyStyle:=WebMessageBodyStyle.WrappedRequest, RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="/MyKit/{AccountID}")> _
    Function GetKit(ByVal AccountID As String) As MyKit
    

    Service:

    Public Function GetKit(ByVal AccountID As String) As MyKit Implements IService1.GetKit
    
        Dim allKit As New MyKit() //Your object
        objDal.CommandText = 'run some sql here - or whatever
    
        Using dr As SqlDataReader = "blah"
    
        //populate your object
    
        End Using
    
        Return allKit //return the object, not the string representation of it
    
    End Function
    

    Using DataContractJsonSerializer for sending as Json to Android from WCF effectively ‘pre-escapes’ the data. When it gets to Android, the Json parser is unable to handle it, because it also escapes the data.

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

Sidebar

Related Questions

I'm trying to convert an existing app to use core data. I've set up
I'm trying to convert my existing site to use WCF to communicate with my
I am trying to convert an existing Android, SQLite database to a multi-platform, SQLite
Trying to convert an existing Android build system using Ant with 'ant_rules_r3.xml' integration from
I am trying to convert a pre-existing site that had html and php intermingled
I am trying to convert some pre-existing html/JavaScript files to Flex. I tried making
Trying to convert this c code into MIPS and run it in SPIM. int
I am trying to migrate existing code that uses XmlSerializer to protobuf-net due to
I'm trying to convert an existing SVN repository to GIT using git-svn clone but
I'm trying to to convert an existing PHP regular expression to apply to a

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.