0

I am trying to develop a metro-style app using C# and XAML. In that app, I am getting some data in JSON-formatted string from a service. A sample is shown below:

  [{
    "displayFieldName" : "OBJECT_NAME", 
    "fieldAliases" : {
        "OBJECT_NAME" : "OBJECT_NAME", 
        "OBJECT_TYPE" : "OBJECT_TYPE"
    }, 
    "positionType" : "point", 
    "reference" : {
        "id" : 1111
    }, 
    "objects" : [ {
        "attributes" : {
            "OBJECT_NAME" : "test name", 
            "OBJECT_TYPE" : "test type"
        }, 
        "position" : {
            "x" : 5, 
            "y" : 7
        }
    } ]
}]

Actually I am getting the data as a single line, a very long line. Anyway, I want to process it in C# as a JSON-object. How can I do that, convert that string to a C# object?

1

2 Answers 2

1

You can use inbuilt json serializer/Deserializer or use third party tools such as Json.NET.

Sign up to request clarification or add additional context in comments.

Comments

0

I ran into this issue the other day.
I was able to parse it using JsonArray.Parse.

Another solution was to wrap the array in an object like this:

{ items: <original string here> }

Then you can use JsonObject.Parse to retrieve an object.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.