0

I'm using this plugin http://devthought.com/projects/jquery/textboxlist/ to autocomplete like Facebook Style. I'm just a bit confuse on how to return the Json result that fits the plugin's need.

The json result must be like this:

[[1, 'John', null, ''],[2,'Mary', null, ''],[3,'Mark', null, '']]

The problem is when I return the result to my View:

return Json(myjSon, JsonRequestBehavior.AllowGet);

This is the result:

"[[1, \u0027John\u0027, null, \u0027\u0027],[2, \u0027Maryn\u0027, null, \u0027\u0027],[3, \u0027Mark\u0027, null, \u0027\u0027]]"

The aposthrophe was converted to \u0027 and its ruining my code. What should I do?

1
  • can you clarify the type of "myjSon" object that you are returning to your view. Commented Sep 10, 2010 at 2:17

1 Answer 1

3

You just did wrong type of myjSon, which should be an object not string.

var myjSon = new[]{
    new object[]{1,"John", null, ""},
    new object[]{2,"Mary", null, ""},
    new object[]{3,"Mark", null, ""}
};
return Json(myjSon, JsonRequestBehavior.AllowGet); 

EDIT: code corrected according to the comments

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

3 Comments

Hi Dennis, I tried exactly what you said but I got this error message: No best type found for implicitly-typed array
It complains about the new[] inside the main new[] { .... }; Can you help me with that please? Thanks!
@Guillermo change the inner new [] to new object[] and that should work. The compiler is complaining because you have strings and ints in the array and it doesn't know which type to use

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.