Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi 

Can you please someone help me to process the below Json string value, Please highlight the data inside  parseValue like Message.ID, Message.Version , Message.Val.ValMessage.optionalAdditionalData.data. 

{"no":"194","id":"011049150083","parseValue":[{"Message.ID":"1","Message.Version":"2","Message.Val.ValMessage.optionalAdditionalData.data":"F2A51"}]}";

Appreciate your response 


What I have tried:

I am not able to process the value which is marked as
Message.ID, Message.Version
Posted
Updated 23-Oct-18 3:59am
Comments
j snooze 22-Oct-18 17:15pm    
if you're in c# I very much recommend you study up and search examples on using the newtonsoft json nuget package. wonderful for turning json objects into C# objects.

Look at Serializing and Deserializing the Json

Json Deserialize
 
Share this answer
 
Using JSON.NET[^], you would need to use the JsonProperty attribute[^] to specify the property name.

For example:
C#
public class ParseValue
{
    [JsonProperty("Message.ID")]
    public string MessageId { get; set; }

    [JsonProperty("Message.Version")]
    public string MessageVersion { get; set; }

    [JsonProperty("Message.Val.ValMessage.optionalAdditionalData.data")]
    public string MessageAdditionalData { get; set; }
}

public class Root
{
    [JsonProperty("no")]
    public string No { get; set; }

    [JsonProperty("id")]
    public string Id { get; set; }

    [JsonProperty("parseValue")]
    public ParseValue[] ParseValue { get; set; }
}

...

Root data = JsonConvert.DeserializeObject<Root>(jsonString);
 
Share this answer
 
For additional information on JSON deserialization, check out this in-depth article that was put together base on questions asked here: Working with JSON in C# & VB[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900