Exemplo n.º 1
0
        /// <summary>
        /// Parses the specified |jsonString| and returns a dictionary or list
        /// representation. If JSON parsing fails this function returns NULL and
        /// populates |errorCodeOut| and |errorMsgOut| with an error code and a
        /// formatted error message respectively.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static CfxValue ParseJsonAndReturnError(string jsonString, CfxJsonParserOptions options, out CfxJsonParserError errorCodeOut, ref string errorMsgOut)
        {
            var    jsonString_pinned = new PinnedString(jsonString);
            int    errorCodeOut_tmp;
            var    errorMsgOut_pinned = new PinnedString(errorMsgOut);
            IntPtr errorMsgOut_str    = errorMsgOut_pinned.Obj.PinnedPtr;
            int    errorMsgOut_length = errorMsgOut_pinned.Length;
            var    __retval           = CfxApi.cfx_parse_jsonand_return_error(jsonString_pinned.Obj.PinnedPtr, jsonString_pinned.Length, (int)options, out errorCodeOut_tmp, ref errorMsgOut_str, ref errorMsgOut_length);

            jsonString_pinned.Obj.Free();
            errorCodeOut = (CfxJsonParserError)errorCodeOut_tmp;
            if (errorMsgOut_str != errorMsgOut_pinned.Obj.PinnedPtr)
            {
                if (errorMsgOut_length > 0)
                {
                    errorMsgOut = System.Runtime.InteropServices.Marshal.PtrToStringUni(errorMsgOut_str, errorMsgOut_length);
                    // free the native string?
                }
                else
                {
                    errorMsgOut = null;
                }
            }
            errorMsgOut_pinned.Obj.Free();
            return(CfxValue.Wrap(__retval));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses the specified |jsonString| and returns a dictionary or list
        /// representation. If JSON parsing fails this function returns NULL.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static CfxValue ParseJson(string jsonString, CfxJsonParserOptions options)
        {
            var jsonString_pinned = new PinnedString(jsonString);
            var __retval          = CfxApi.cfx_parse_json(jsonString_pinned.Obj.PinnedPtr, jsonString_pinned.Length, (int)options);

            jsonString_pinned.Obj.Free();
            return(CfxValue.Wrap(__retval));
        }