简体   繁体   English

经典的ASP服务器端JSON库

[英]Classic ASP server-side JSON library

I have inherited some Classic ASP code and I need a JSON library that can be instantiated and run server-side for use with JavaScript-coded server-side ASP. 我继承了一些经典ASP代码,我需要一个可以实例化的JSON库,并在服务器端运行,以便与JavaScript编码的服务器端ASP一起使用。

How can I do this? 我怎样才能做到这一点?

In my experience, JSON2.js works in Classic ASP. 根据我的经验, JSON2.js适用于Classic ASP。

To use it, I do this in the .asp code: 要使用它,我在.asp代码中执行此操作:

<%@ language="Javascript" %>

<script language="javascript" runat="server" src='json2.js'></script>

<script language="javascript" runat="server">

   ... my code here....

   // use the JSON object:
   var jsonRepresentation = JSON.stringify(myObject, null, 2);

</script>

For writing/outputting JSON i believe the aspjson project is a pretty good choice. 对于编写/输出JSON,我相信aspjson项目是一个不错的选择。 Parsing JSON in ASP "classic" is discussed here: 这里讨论解析ASP“经典”中的JSON:

In that thread, Chris Nielsen has a creative idea of using a Javascript library on the server side (as ASP supports JScript as well as VBScript). 在那个主题中,Chris Nielsen有一个创造性的想法,即在服务器端使用Javascript库(因为ASP支持JScript和VBScript)。 I have not tried it, but maybe that could solve both parsing and writing. 我没有尝试过,但也许这可以解决解析和写作问题。

I've used aspjson with great success. 我使用了aspjson取得了巨大的成功。

http://code.google.com/p/aspjson/ http://code.google.com/p/aspjson/

You could try something similar to this: http://www.lshift.net/blog/2005/10/11/simple-ajax-with-json-chat-application-for-asp-30 你可以尝试类似的东西: http//www.lshift.net/blog/2005/10/11/simple-ajax-with-json-chat-application-for-asp-30

It has a fairly direct encapsulation of the old json.js into a json.asp file for running on the server-side. 它将旧的json.js直接封装到json.asp文件中,以便在服务器端运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM