0
我會開始說我對JSON不是很熟悉。將JSON發佈到WebAPI - JSON對象包含圖像(字節) - 獲取錯誤:表達式太長或編譯複雜
我正在創建一個Web服務,它將接受來自iOS設備的JSON數據,並將該數據插入到數據庫中。
我遇到的麻煩是圖像字節數據很大。這導致服務器端錯誤「一個表達式太長或者很難編譯」。
這裏的JSON數據和JavaScript的AJAX調用:
var source = {
"longitude": 96.84610000000001,
"latitude": 35.5608,
"username": "blah",
"imageDataBlob": "\/9j\/4UI5RXhpZgAASUkqAAgAAAAKAA8BAgASAAAAhgAAABABAgALAAAAmAAA\nABoBBQABAAAApAAAABsBBQABAAAArAAAACgBAwABAAAAAgAAADEBAgAJAAAA\ntAAAADIBAgAUAAAAvgAAADsBAgAPAAAA0gAAAJiCAgAdAAAA4gAAAGmHBAAB\nAAAAAAEAAAgDAABOSUtPTiBDT1JQT1JBVElPTgBOSUtPTiBENzAwAAD6AAAA\nAQAAAPoAAAABAAAAVmVyLjEuMDEAADIwMTA6MDc6MTQgMDM6MzE6NTEATmFz\naW0gTWFuc3Vyb3YAAENvcHlyaWdodCAoQykgTmFzaW0gTWFuc3Vyb3YAACAA\nmoIFAAEAAACGAgAAnYIFAAEAAACOAgAAIogDAAEAAAADAAAAJ4gDAAEAAADI\nAAAAAJAHAAQAAAAwMjIxA5ACABQAAACWAgAABJACABQAAACqAgAAAZIKAAEA\nAAC+AgAAApIFAAEAAADGAgAABJIKAAEAAADOAgAABZIFAAEAAADWAgAAB5ID\nAAEAAAAFAAAACJIDAAEAAAAAAAAACZIDAAEAAAAAAAAACpIFAAEAAADeAgAA\nhpIHABoAAADmAgAAkZICAAMAAAA3NAAAkpICAAMAAAA3NAAAF6IDAAEAAAAC\nAAAAAKMHAAEAAAADAAAAAaMHAAEAAAABAAAAAaQDAAEAAAAAAAAAAqQDAAEA\nAAAAAAAAA6QDAAEAAAAAAAAABKQFAAEAAAAAAwAABaQDAAEAAAA...etc"
}
$.ajax({
type: "POST",
dataType: "json",
url: "/api/blah/PostPicture/",
data: source
});
如果我需要用JSON數據的工作傳遞給我的web服務,我怎麼能面對如此巨大的JSON對象工作嗎?有沒有我可以修改我的web.config允許這個配置設置?
*「一個表達式太長或者很難編譯。」*我猜這是.NET端的服務器端錯誤? – epascarello 2013-04-29 17:35:55
是的,這是服務器端錯誤。 – 2013-04-29 17:36:13
你用什麼JSON庫轉換它? – epascarello 2013-04-29 17:37:24