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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:10:18+00:00 2026-05-30T05:10:18+00:00

i have some Objects serialized with the System.Runtime.Serialization.Json.DataContractJsonSerializer and written to my Database: Dim

  • 0

i have some Objects serialized with the System.Runtime.Serialization.Json.DataContractJsonSerializer and written to my Database:

Dim serializer = New DataContractJsonSerializer(obj.GetType)
Using ms = New MemoryStream()
    serializer.WriteObject(ms, obj)
    ms.Position = 0
    Using sr = New StreamReader(ms)
        Dim json = sr.ReadToEnd()
        sr.Close()
        Return json
    End Using
End Using

Now i have to change the Classes and add some new Properties.

Then i want to deserialize the “old” strings to the new classes:

Using ms = New MemoryStream(Encoding.UTF8.GetBytes(serialized))
    Dim ser = New DataContractJsonSerializer(GetType(T))
    Return DirectCast(ser.ReadObject(ms), T)
End Using

How can i now deserialize the “old” Strings to the new class? (The new Properties can stay empty)

thank you!

  • 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-30T05:10:19+00:00Added an answer on May 30, 2026 at 5:10 am

    We found a solution for this issue:

    We switched from the DataContractJsonSerializer to JSON.Net.
    The Problem now was, that the JSON.Net serializes with a different naming conventions, so the old serializes Data in the Database could not be Deserialized.
    the DataContractJsonSerializer uses “_propertyname”, ans the JSON.Net uses “propertyname”.

    But fortunalety the JSON.Net Serializer allowed us to overwrite the Naming Generation with a small class:

     Public Class UnderscorePropertyNamesContractResolver
        Inherits Newtonsoft.Json.Serialization.DefaultContractResolver
    
        Protected Overrides Function ResolvePropertyName(propertyName As String) As String
            Return MyBase.ResolvePropertyName("_" + propertyName)
        End Function
    End Class
    

    Which could be then used this was with the old JSON Data:

     Dim Setting = New JsonSerializerSettings
     Setting.ContractResolver = New UnderscorePropertyNamesContractResolver
     return JsonConvert.DeserializeObject(Of T)(serialized, Setting)
    

    and do the Seralisation with this:

    Dim Setting = New JsonSerializerSettings
    Setting.ContractResolver = New UnderscorePropertyNamesContractResolver
    return JsonConvert.SerializeObject(obj, Formatting.Indented, Setting)
    

    Now we have a more fault tollerant JSON Serialisation and can add Properties to our classes with the old JSON Data.

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

Sidebar

Related Questions

I'd prefer to use Microsofts System.Runtime.Serialization.Json.DataContractJsonSerializer to serialize my objects in JSON so I
When serializing an object using the System.Runtime.Serialization.Json.DataContractJsonSerializer , is there a way to set
We have code like: ms = New IO.MemoryStream bin = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bin.Serialize(ms, largeGraphOfObjects)
I have some simple .NET objects I'd like to serialize to JSON and back
Lets say I have some domain objects that will need to be serialized/packed using
Assume you have some objects which have several fields they can be compared by:
I have a question with fluent interfaces. We have some objects that are used
I have some model objects I'm using in my Java client application. Later these
I have some business objects which use: Web.Configuration.WebConfigurationManager.AppSettings.Item(SomeSetting) Now that I'm breaking those objects
I have some NSDictionary objects stored in an NSArray called telephoneArray . I fetch

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.