Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 410 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'JSON' is null or not an object' error in classic ASP

#1
I'm getting the error in the title --JSON is null or not an object.

I am inside a classic ASP page. My json2.js file is located in the same directory as this classic asp page that I'm in. So I have no idea why the server can't seem to recognize the JSON.parse() method.
My scripting language is JScript.

I noticed that in a different thread, using the json2.js library is the way to go. But I can't seem to get this to work. Is this a quirk? This should be very straightforward, no?

requestBody is a simple JSON object: [{"answer":"ok"},{"answer":"sunny"}]

Thanks!

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

<%
var jsonObject = JSON.parse(requestBody);

%>
Reply

#2
The .NET Framework 3.5 has the [JavaScriptSerializer][1] class that can help in deserialization of a json object. You can also use third party libraries like [JSON.NET][2].




[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#3
Should work, just made quick test case.

Things to try on your side:

1. Try to rename the included file to `json2.asp` and change to:

<script language="javascript" runat="server" src="json2.asp"></script>
There might be problem with the mime type and such stuff.

2. If no luck, leave the file renamed and try browsing directly to `json2.asp` with the browser, instead to your own page.

3. Try adding some debug code to the included file, and see if it's being executed.

If still no luck, please also specify what exact server you're using and what platform and maybe somebody will have fresh ideas.
Reply

#4
Not sure, but the first thing I would do is check the permissions on json2.js. Use icacls.exe, and verify that the permissions on that file match the perms on the .ASP page itself. I do this:

%windir%\system32\icacls.exe json2.js /grant "NT AUTHORITY\IUSR:(RX)"
%windir%\system32\icacls.exe json2.js /grant "BUILTIN\IIS_IUSRS:(RX)"


Also - to help debug ASP you can fiddle with the ASP debugging settings in IIS Manager. Click "Send errors to client" to see the errors in the client browser window.

Alternatively, you can manually add this to web.config:

<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" existingResponse="PassThrough" />
<asp scriptErrorSentToBrowser="false" />
</system.webServer>
</configuration>



On Vista/2008/Win7, you may also need to "unlock" the web.config stanza that permits this.

%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/asp


This won't fix the "JSON not an object" problem, but it will give you better error messages when failures occur.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through