91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 57KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-04
  • 語言: C#
  • 標簽: c#??json??校驗??

資源簡介

c#版本的校驗文本是否為合法json格式,單獨一個類無需其他引用

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;

namespace?CheckJSON
{
????internal?class?JsonSplit
????{
????????private?static?bool?IsJsonstart(ref?string?json)
????????{
????????????if?(!string.IsNullOrEmpty(json))
????????????{
????????????????json?=?json.Trim(‘\r‘?‘\n‘?‘?‘);
????????????????if?(json.Length?>?1)
????????????????{
????????????????????char?s?=?json[0];
????????????????????char?e?=?json[json.Length?-?1];
????????????????????return?(s?==?‘{‘?&&?e?==?‘}‘)?||?(s?==?‘[‘?&&?e?==?‘]‘);
????????????????}
????????????}
????????????return?false;
????????}
????????internal?static?bool?IsJson(string?json)
????????{
????????????int?errIndex;
????????????return?IsJson(json?out?errIndex);
????????}
????????internal?static?bool?IsJson(string?json?out?int?errIndex)
????????{
????????????errIndex?=?0;
????????????if?(IsJsonstart(ref?json))
????????????{
????????????????CharState?cs?=?new?CharState();
????????????????char?c;
????????????????for?(int?i?=?0;?i?????????????????{
????????????????????c?=?json[i];
????????????????????if?(SetCharState(c?ref?cs)?&&?cs.childrenStart)//設置關鍵符號狀態。
????????????????????{
????????????????????????string?item?=?json.Substring(i);
????????????????????????int?err;
????????????????????????int?length?=?GetValueLength(item?true?out?err);
????????????????????????cs.childrenStart?=?false;
????????????????????????if?(err?>?0)
????????????????????????{
????????????????????????????errIndex?=?i?+?err;
????????????????????????????return?false;
????????????????????????}
????????????????????????i?=?i?+?length?-?1;
????????????????????}
????????????????????if?(cs.isError)
????????????????????{
????????????????????????errIndex?=?i;
????????????????????????return?false;
????????????????????}
????????????????}

????????????????return?!cs.arrayStart?&&?!cs.jsonstart;
????????????}
????????????return?false;
????????}

????????///?
????????///?獲取值的長度(當Json值嵌套以“{“或“[“開頭時)
????????///?

????????private?static?int?GetValueLength(string?json?bool?breakOnErr?out?int?errIndex)
????????{
????????????errIndex?=?0;
????????????int?len?=?0;
????????????if?(!string.IsNullOrEmpty(json))
????????????{
????????????????CharState?cs?=?new?CharState();
????????????????char?c;
????????????????for?(int?i?=?0;?i?????????????????{
????????????????????c?=?json[i];
????????????????????if?(!SetCharState(c?ref?cs))//設置關鍵符號狀態。
????????????????????{
????????????????????????if?(!cs.jsonstart?&&?!cs.arrayStart)//json結束,又不是數組,則退出。
????????????????????????{
????????????????????????????break;
????????????????????????}
????????????????????}
????????????????????else?if?(cs.childrenStart)//正常字符,值狀態下。
????????????????????{
????????????????????????int?length?=?GetValueLength(json.Substring(i)?breakOnErr?out?errIndex);//遞歸子值,返回一個長度。。。
????????????????????????cs.childrenStart?=?fa

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????12288??2015-08-28?16:11??CheckJSON\CheckJSON\bin\Debug\CheckJSON.exe

?????文件??????32256??2015-08-28?16:11??CheckJSON\CheckJSON\bin\Debug\CheckJSON.pdb

?????文件??????22472??2015-08-31?08:53??CheckJSON\CheckJSON\bin\Debug\CheckJSON.vshost.exe

?????文件????????490??2012-06-06?02:06??CheckJSON\CheckJSON\bin\Debug\CheckJSON.vshost.exe.manifest

?????文件???????3768??2015-08-28?14:12??CheckJSON\CheckJSON\CheckJSON.csproj

?????文件??????16252??2015-08-28?14:12??CheckJSON\CheckJSON\Class1.cs

?????文件???????1107??2015-08-28?16:11??CheckJSON\CheckJSON\Form1.cs

?????文件???????2022??2015-08-28?14:12??CheckJSON\CheckJSON\Form1.Designer.cs

?????文件???????5817??2015-08-28?14:12??CheckJSON\CheckJSON\Form1.resx

?????文件????????882??2015-08-31?08:53??CheckJSON\CheckJSON\obj\Debug\CheckJSON.csproj.FileListAbsolute.txt

?????文件????????975??2015-08-28?16:10??CheckJSON\CheckJSON\obj\Debug\CheckJSON.csproj.GenerateResource.Cache

?????文件???????2209??2015-08-28?16:10??CheckJSON\CheckJSON\obj\Debug\CheckJSON.csprojResolveAssemblyReference.cache

?????文件??????12288??2015-08-28?16:11??CheckJSON\CheckJSON\obj\Debug\CheckJSON.exe

?????文件????????180??2015-08-28?16:10??CheckJSON\CheckJSON\obj\Debug\CheckJSON.Form1.resources

?????文件??????32256??2015-08-28?16:11??CheckJSON\CheckJSON\obj\Debug\CheckJSON.pdb

?????文件????????180??2015-08-28?16:10??CheckJSON\CheckJSON\obj\Debug\CheckJSON.Properties.Resources.resources

?????文件???????1451??2015-08-31?08:53??CheckJSON\CheckJSON\obj\Debug\DesignTimeResolveAssemblyReferences.cache

?????文件???????6905??2015-08-28?14:11??CheckJSON\CheckJSON\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

?????文件????????490??2015-08-28?14:05??CheckJSON\CheckJSON\Program.cs

?????文件???????1338??2015-08-28?14:05??CheckJSON\CheckJSON\Properties\AssemblyInfo.cs

?????文件???????2870??2015-08-28?14:05??CheckJSON\CheckJSON\Properties\Resources.Designer.cs

?????文件???????5612??2015-08-28?14:05??CheckJSON\CheckJSON\Properties\Resources.resx

?????文件???????1096??2015-08-28?14:05??CheckJSON\CheckJSON\Properties\Settings.Designer.cs

?????文件????????249??2015-08-28?14:05??CheckJSON\CheckJSON\Properties\Settings.settings

?????文件????????917??2015-08-28?14:05??CheckJSON\CheckJSON.sln

????..A..H.????331264??2015-08-31?08:58??CheckJSON\CheckJSON.v11.suo

?????目錄??????????0??2015-08-28?14:05??CheckJSON\CheckJSON\obj\Debug\TempPE

?????目錄??????????0??2015-08-28?16:10??CheckJSON\CheckJSON\bin\Debug

?????目錄??????????0??2015-08-31?08:53??CheckJSON\CheckJSON\obj\Debug

?????目錄??????????0??2015-08-28?14:05??CheckJSON\CheckJSON\bin

............此處省略7個文件信息

評論

共有 條評論