-4

I'm somehow having troubles deserializing a json string into a simple List or string[] (I don't care which).

As of what I know, this is how to do this job:

JsonConvert.DeserializeObject<List<string>>(jsonString);

Here I am getting a RuntimeBinderException. It complains about the parameter, although my json string is valid and simple: a:1:{i:0;s:10:"Sahibinden";}

4
  • 5
    Your JSON isn't valid. Paste it into json2csharp.com. If you haven't given us the full string, please do so. Commented Jan 5, 2017 at 15:23
  • 1
    Your JSON is also not an array, so it cannot be deserialized into a list. Commented Jan 5, 2017 at 15:24
  • I didn't know there were different json syntaxs between programming languages. Here it worked: unserialize.com/s/06402092-abe2-3969-82f4-0000513f719e Thanks guys, I will do some research. Commented Jan 5, 2017 at 15:29
  • There are not different JSON syntax between programming languages. There are different serialization syntax between them. A serialized object is not a JSON object. Commented Jan 5, 2017 at 15:41

2 Answers 2

1

What you have isn't JSON is a serialized PHP object. There have been some tools that work well with this in C# but there isn't native support. If you own the PHP, then convert the object/array to JSON first. If not try the information on this question: https://stackoverflow.com/a/1923626/474702

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

Comments

0

Your JSON is invalid. Problems:

  1. a:1 should be inside an object bracket of {}

  2. The : before the { is invalid, you need a , there

  3. The ; just after i:0 is invalid, you need a comma there

  4. You repeat the mistake described in 1. and 2. inside your {} brackets as well

Solution: You need to read about JSON and make sure you understand its syntax.

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.