JSON.Stringify fails on Scripting.Dictionary objects

前端 未结 3 617
暗喜
暗喜 2021-01-07 03:58

I am working on an ASP classic project where I have implemented the JScript JSON class found here. It is able to interop with both VBScript and JScript and is almost exactly

3条回答
  •  渐次进展
    2021-01-07 05:04

    JSON does not inherently encode any type information at all. What JSON enables you to represent is an arbitrary data structure involving either an object or an array of values. Any such object may have an arbitrary number of named properties such that the names are strings and the values are either the constant null, the constants true or false, numbers, strings, objects, or arrays of values.

    How such a data structure is realized in any given programming language runtime is your problem :-) For example, when de-serializing JSON into Java, one might use ArrayList instances for arrays, HashMap instances for objects, and native types for simpler values. However, it might be that you really want the objects to be some particular type of Java bean class. To do that, the JSON parser involved would have to be somehow guided as to what sort of objects to instantiate. Exactly how that works depends on the JSON parser and its APIs.

    (edit — when I said "no type information at all", I meant for "object" values; clearly booleans, strings, and numbers have obvious types.)

提交回复
热议问题