如何使WebService仅返回JSON而不是XML内部的JSON?

时间:2019-01-04 23:17:57

标签: json

我正在尝试让我的WebService返回XML标签内的JSON对象而不是JSON。

我有以下方法:

当我测试此方法时,我不断得到结果:

exit status 3221225477

如何让我的Web服务仅返回JSON对象而不返回XML文档内部?我尝试执行以下操作:

1)在我的axios调用标题中设置package main import ( "fmt" "github.com/go-gl/gl/v4.1-core/gl" "github.com/veandco/go-sdl2/sdl" ) var ( window *sdl.Window context sdl.GLContext ) func main() { // Initialize sdl and create context initialize() // Initialize OpenGL pointers gl.Init() // Setup opengl attributes setOpenGLAttributes() // This makes our buffer swap syncronized with the monitor's vertical refresh sdl.GLSetSwapInterval(1) // Run and clean run() clean() } func initialize() { sdl.Init(sdl.INIT_EVERYTHING) window, err := sdl.CreateWindow("Test", sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, 1280, 720, sdl.WINDOW_OPENGL) if err != nil { fmt.Println(err) return } context, err = window.GLCreateContext() if err != nil { fmt.Println(err) return } } func setOpenGLAttributes() { // SDL_GL_CONTEXT_CORE gives us only the newer version, deprecated functions are disabled sdl.GLSetAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_CORE) // 3.2 is part of the modern versions of OpenGL, but most video cards whould be able to run it sdl.GLSetAttribute(sdl.GL_CONTEXT_MAJOR_VERSION, 3) sdl.GLSetAttribute(sdl.GL_CONTEXT_MINOR_VERSION, 2) // Turn on double buffering with a 24bit Z buffer. sdl.GLSetAttribute(sdl.GL_DOUBLEBUFFER, 1) } func run() { for { for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() { switch event.(type) { case *sdl.QuitEvent: return } } gl.ClearColor(1, 8, 20, 1.0) gl.Clear(gl.COLOR_BUFFER_BIT) window.GLSwap() } } func clean() { // Delete our OpengL context sdl.GLDeleteContext(context) // Destroy our window window.Destroy() // Shutdown SDL 2 sdl.Quit() } gl.Init()

2)将方法设置为DataTable DataSource = new PersonAddressesModel().Get_PersonAddressesByGuid(orgId, guid); JavaScriptSerializer serializer = new JavaScriptSerializer(); List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>(); Dictionary<string, object> row; foreach (DataRow dr in DataSource.Rows) { row = new Dictionary<string, object>(); foreach (DataColumn col in DataSource.Columns) { row.Add(col.ColumnName, dr[col]); } rows.Add(row); } return serializer.Serialize(rows);

0 个答案:

没有答案