Using the code below,
HttpContext context.Response.ContentType = "application/json";
var data = context.Request;
var sr = new StreamReader(data.InputStream);
var stream = sr.ReadToEnd();
var javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
var obj = javaScriptSerializer.DeserializeObject(stream);
object[] arr = (object[])obj;
The result of arr obtained. The arr is a 3-level array object. E.g., below is the displayed in Watch panel:
Name Value Type
arr[2] {object[3] object{object[]}
[0] {object[2] object{object[]}
[1] {object[2] object{object[]}
[2] {object[2] object{object[]}
[0] "6512" object{string}
[1] "In Invert" object{string}
I tried to get retrieve the values of the elements, e.g. arr[2][2][2], but failed.
Then, from Immediate Window, I retrieved arr[2] (see below).
arr[2].GetType()
{Name = "Object[]" FullName = "System.Object[]"}
[System.RuntimeType]: {Name = "Object[]" FullName = "System.Object[]"}
base {System.Reflection.MemberInfo}: {Name = "Object[]" FullName = "System.Object[]"}
Assembly: {mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
AssemblyQualifiedName: "System.Object[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Attributes: Public | Sealed | Serializable
BaseType: {Name = "Array" FullName = "System.Array"}
ContainsGenericParameters: false
DeclaringMethod: 'obj.GetType().DeclaringMethod' threw an exception of type 'System.InvalidOperationException'
DeclaringType: null
FullName: "System.Object[]"
GenericParameterAttributes: 'obj.GetType().GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'
GenericParameterPosition: 'obj.GetType().GenericParameterPosition' threw an exception of type 'System.InvalidOperationException'
GenericTypeArguments: {System.Type[0]}
GUID: {00000000-0000-0000-0000-000000000000}
HasElementType: true
IsAbstract: false
IsAnsiClass: true
IsArray: true
IsAutoClass: false
IsAutoLayout: true
IsByRef: false
IsClass: true
IsCOMObject: false
IsConstructedGenericType: false
IsContextful: false
IsEnum: false
IsExplicitLayout: false
IsGenericParameter: false
IsGenericType: false
IsGenericTypeDefinition: false
IsImport: false
IsInterface: false
IsLayoutSequential: false
IsMarshalByRef: false
IsNested: false
IsNestedAssembly: false
IsNestedFamANDAssem: false
IsNestedFamily: false
IsNestedFamORAssem: false
IsNestedPrivate: false
IsNestedPublic: false
IsNotPublic: false
IsPointer: false
IsPrimitive: false
IsPublic: true
IsSealed: true
IsSecurityCritical: false
IsSecuritySafeCritical: false
IsSecurityTransparent: true
IsSerializable: true
IsSpecialName: false
IsUnicodeClass: false
IsValueType: false
IsVisible: true
MemberType: TypeInfo
Module: {CommonLanguageRuntimeLibrary}
Namespace: "System"
ReflectedType: null
StructLayoutAttribute: null
TypeHandle: {System.RuntimeTypeHandle}
TypeInitializer: null
UnderlyingSystemType: {Name = "Object[]" FullName = "System.Object[]"}
Since its IsEnm property is false, I don't know how I can get the sub-objects: arr[2][0] and arr[2][1].
I don't know if there is method to convert object[] to object so I can retrieve the sub-objects.
Hopefully, someone can help for this issue. Thanks.
What I have tried:
How to Deserialize object and retrieve the elements' values?