Beispiel #1
0
            /// <summary>
            /// De-serializes the data is <see cref="reader"/> and reconstitutes the graph of objects.
            /// </summary>
            /// <returns>The top object of the deserialized graph. Null in case of error.</returns>
            internal object Deserialize()
            {
                context.Properties.RemoveProperty <PhpJson.JsonLastError>();

                var scanner = new JsonScanner(reader, decodeOptions);
                var parser  = new Json.Parser(context, decodeOptions)
                {
                    Scanner = scanner
                };

                try
                {
                    if (!parser.Parse())
                    {
                        throw new Exception("Syntax error");
                    }
                }
                catch (Exception)
                {
                    context.Properties.SetProperty <PhpJson.JsonLastError>(PhpJson.JsonLastError.JSON_ERROR_SYNTAX);
                    return(null);
                }

                //
                return(parser.Result);
            }
Beispiel #2
0
            /// <summary>
            /// De-serializes the data is <see cref="reader"/> and reconstitutes the graph of objects.
            /// </summary>
            /// <returns>The top object of the deserialized graph. Null in case of error.</returns>
            internal object Deserialize()
            {
                var scanner = new JsonScanner(reader, decodeOptions);
                var parser  = new Json.Parser(context, decodeOptions)
                {
                    Scanner = scanner
                };

                try
                {
                    if (!parser.Parse())
                    {
                        throw new Exception("Syntax error");
                    }
                }
                catch (Exception)
                {
                    PhpJson.LastError = PhpJson.JsonLastError.JSON_ERROR_SYNTAX;
                    return(null);
                }

                PhpJson.LastError = PhpJson.JsonLastError.JSON_ERROR_NONE;
                return(parser.Result);
            }