Skip to content

Commit cb85306

Browse files
committed
v1.0.0.8
- Fix export, save and saveas to output correct text based json using cJSON_PrintBuffered - Ignore shortcut keys for Save and SaveAs if no json data. Signed-off-by: mrfearless <[email protected]>
1 parent 04999c2 commit cb85306

17 files changed

+712
-1087
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
Application that utilizes cJSON (https://github.com/DaveGamble/cJSON) for reading .json files and displaying the nodes in a treeview control.
44

5-
Built with statically compiled json v1.7.12 x86 library (https://github.com/mrfearless/libraries/tree/master/cJSON)
5+
Built with the following statically compiled libraries:
6+
7+
- json v1.7.12 x86 (https://github.com/mrfearless/libraries/tree/master/cJSON)
8+
- VirtualStack x86 (https://github.com/mrfearless/libraries/tree/master/VirtualStack)
9+
- Treeview x86 (https://github.com/mrfearless/libraries/tree/master/Treeview)
10+
- Masm32 x86 (http://masm32.com/download.htm)
611

712
From a post on tuts4you.com: https://forum.tuts4you.com/topic/39996-how-to-read-json-correctly/

Res/cjsontreeMnu.Rc

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
#define IDM_FILE_EXIT 10001
88
#define IDM_EDIT_COPY 10201
99
#define IDM_EDIT_COPY_VALUE 10202
10-
#define IDM_EDIT_COPY_ITEM 10203
11-
#define IDM_EDIT_COPY_BRANCH 10204
12-
#define IDM_EDIT_PASTE_ITEM 10205
13-
#define IDM_EDIT_PASTE_BRANCH 10206
14-
#define IDM_EDIT_PASTE_JSON 10207
15-
#define IDM_EDIT_FIND 10208
10+
#define IDM_EDIT_COPY_ITEM 10205
11+
#define IDM_EDIT_COPY_BRANCH 10206
12+
#define IDM_EDIT_PASTE_ITEM 10207
13+
#define IDM_EDIT_PASTE_BRANCH 10208
14+
#define IDM_EDIT_PASTE_JSON 10209
15+
#define IDM_EDIT_FIND 10210
1616
#define IDM_OPTIONS_EXPANDALL 10301
1717
#define IDM_OPTIONS_CASESEARCH 10302
1818
#define IDM_HELP_ABOUT 10101

Res/cjsontreeVer.rc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#define VERINF1 1
22
VERINF1 VERSIONINFO
3-
FILEVERSION 1,0,0,6
4-
PRODUCTVERSION 1,0,0,6
3+
FILEVERSION 1,0,0,8
4+
PRODUCTVERSION 1,0,0,8
55
FILEOS 0x00000004
66
FILETYPE 0x00000001
77
BEGIN
@@ -10,14 +10,14 @@ BEGIN
1010
BLOCK "040904B0"
1111
BEGIN
1212
VALUE "CompanyName", "fearless\0"
13-
VALUE "FileVersion", "1.0.0.6\0"
13+
VALUE "FileVersion", "1.0.0.8\0"
1414
VALUE "FileDescription", "cjsontree x86\0"
1515
VALUE "InternalName", "cjsontree\0"
1616
VALUE "LegalCopyright", "fearless\0"
1717
VALUE "LegalTrademarks", "fearless\0"
1818
VALUE "OriginalFilename", "cjsontree\0"
1919
VALUE "ProductName", "cjsontree x86\0"
20-
VALUE "ProductVersion", "1.0.0.6\0"
20+
VALUE "ProductVersion", "1.0.0.8\0"
2121
END
2222
END
2323
BLOCK "VarFileInfo"

Treeview.lib

0 Bytes
Binary file not shown.

cjson_x86.inc

+304
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
;
2+
; Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
3+
;
4+
; Permission is hereby granted, free of charge, to any person obtaining a copy
5+
; of this software and associated documentation files (the "Software"), to deal
6+
; in the Software without restriction, including without limitation the rights
7+
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
; copies of the Software, and to permit persons to whom the Software is
9+
; furnished to do so, subject to the following conditions:
10+
;
11+
; The above copyright notice and this permission notice shall be included in
12+
; all copies or substantial portions of the Software.
13+
;
14+
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
; THE SOFTWARE.
21+
;
22+
; https://github.com/DaveGamble/cJSON
23+
;
24+
; cjson.inc converted from cJSON.h 1.7.12 for masm by fearless 2019
25+
;
26+
; https://github.com/mrfearless/libraries/tree/master/cJSON
27+
28+
29+
include msvcrt.inc
30+
includelib msvcrt.lib
31+
includelib msvcrt14.lib
32+
33+
; cJSON project version
34+
CJSON_VERSION_MAJOR EQU 1
35+
CJSON_VERSION_MINOR EQU 7
36+
CJSON_VERSION_PATCH EQU 12
37+
38+
; cJSON Types:
39+
cJSON_Invalid EQU 0; (0)
40+
cJSON_False EQU 1; (1 << 0)
41+
cJSON_True EQU 2; (1 << 1)
42+
cJSON_NULL EQU 4; (1 << 2)
43+
cJSON_Number EQU 8; (1 << 3)
44+
cJSON_String EQU 16; (1 << 4)
45+
cJSON_Array EQU 32; (1 << 5)
46+
cJSON_Object EQU 64; (1 << 6)
47+
cJSON_Raw EQU 128; (1 << 7) - raw json
48+
49+
cJSON_IsReference EQU 256
50+
cJSON_StringIsConst EQU 512
51+
52+
53+
54+
; The cJSON structure:
55+
cJSON STRUCT
56+
next DWORD ?
57+
prev DWORD ?
58+
child DWORD ?
59+
itemtype DWORD ?
60+
valuestring DWORD ?
61+
valueint DWORD ?
62+
valuedouble QWORD ?
63+
itemstring DWORD ?
64+
cJSON ENDS
65+
66+
cJSON_Hooks STRUCT
67+
malloc_fn DWORD ?
68+
free_fn DWORD ?
69+
cJSON_Hooks ENDS
70+
71+
cJSON_bool TYPEDEF DWORD
72+
73+
CJSON_NESTING_LIMIT EQU 1000
74+
75+
76+
cJSON_Version PROTO
77+
cJSON_InitHooks PROTO :DWORD ; (cJSON_Hooks* hooks);
78+
cJSON_Parse PROTO :DWORD ; (const char *value);
79+
cJSON_ParseWithOpts PROTO :DWORD, :DWORD, :DWORD ; (const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
80+
cJSON_Print PROTO :DWORD ; (const cJSON *item);
81+
cJSON_PrintUnformatted PROTO :DWORD ; (const cJSON *item);
82+
cJSON_PrintBuffered PROTO :DWORD, :DWORD, :DWORD ; (const cJSON *item, int prebuffer, cJSON_bool fmt);
83+
cJSON_PrintPreallocated PROTO :DWORD, :DWORD, :DWORD, :DWORD ; (cJSON *item, char *buffer, const int length, const cJSON_bool format);
84+
cJSON_Delete PROTO :DWORD ; (cJSON *c);
85+
cJSON_GetArraySize PROTO :DWORD ; (const cJSON *array);
86+
cJSON_GetArrayItem PROTO :DWORD, :DWORD ; (const cJSON *array, int index);
87+
cJSON_GetObjectItem PROTO :DWORD, :DWORD ; (const cJSON * const object, const char * const string);
88+
cJSON_GetObjectItemCaseSensitive PROTO :DWORD, :DWORD ; (const cJSON * const object, const char * const string);
89+
cJSON_HasObjectItem PROTO :DWORD, :DWORD ; (const cJSON *object, const char *string);
90+
cJSON_GetErrorPtr PROTO
91+
92+
cJSON_GetStringValue PROTO :DWORD ; (cJSON *item);
93+
94+
95+
; These functions check the type of an item
96+
cJSON_IsInvalid PROTO :DWORD ; (const cJSON * const item);
97+
cJSON_IsFalse PROTO :DWORD ; (const cJSON * const item);
98+
cJSON_IsTrue PROTO :DWORD ; (const cJSON * const item);
99+
cJSON_IsBool PROTO :DWORD ; (const cJSON * const item);
100+
cJSON_IsNull PROTO :DWORD ; (const cJSON * const item);
101+
cJSON_IsNumber PROTO :DWORD ; (const cJSON * const item);
102+
cJSON_IsString PROTO :DWORD ; (const cJSON * const item);
103+
cJSON_IsArray PROTO :DWORD ; (const cJSON * const item);
104+
cJSON_IsObject PROTO :DWORD ; (const cJSON * const item);
105+
cJSON_IsRaw PROTO :DWORD ; (const cJSON * const item);
106+
107+
; These calls create a cJSON item of the appropriate type.
108+
cJSON_CreateNull PROTO
109+
cJSON_CreateTrue PROTO
110+
cJSON_CreateFalse PROTO
111+
cJSON_CreateBool PROTO :DWORD ; (cJSON_bool boolean);
112+
cJSON_CreateNumber PROTO :QWORD ; (double num);
113+
cJSON_CreateString PROTO :DWORD ; (const char *string);
114+
; raw json
115+
cJSON_CreateRaw PROTO :DWORD ; (const char *raw);
116+
cJSON_CreateArray PROTO
117+
cJSON_CreateObject PROTO
118+
119+
; Create a string where valuestring references a string so it will not be freed by cJSON_Delete
120+
cJSON_CreateStringReference PROTO :DWORD ; (const char *string);
121+
122+
; Create an object/arrray that only references it's elements so they will not be freed by cJSON_Delete
123+
cJSON_CreateObjectReference PROTO :DWORD ; (const cJSON *child);
124+
cJSON_CreateArrayReference PROTO :DWORD ; (const cJSON *child);
125+
126+
; These utilities create an Array of count items.
127+
cJSON_CreateIntArray PROTO :DWORD, :DWORD ; (const int *numbers, int count);
128+
cJSON_CreateFloatArray PROTO :DWORD, :DWORD ; (const float *numbers, int count);
129+
cJSON_CreateDoubleArray PROTO :DWORD, :DWORD ; (const double *numbers, int count);
130+
cJSON_CreateStringArray PROTO :DWORD, :DWORD ; (const char **strings, int count);
131+
132+
; Append item to the specified array/object.
133+
cJSON_AddItemToArray PROTO :DWORD, :DWORD ; (cJSON *array, cJSON *item);
134+
cJSON_AddItemToObject PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object, const char *string, cJSON *item);
135+
; Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the; cJSON object.
136+
; WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst); is zero before writing to `item->string`
137+
cJSON_AddItemToObjectCS PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object, const char *string, cJSON *item);
138+
; Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON.
139+
cJSON_AddItemReferenceToArray PROTO :DWORD, :DWORD ; (cJSON *array, cJSON *item);
140+
cJSON_AddItemReferenceToObject PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object, const char *string, cJSON *item);
141+
142+
; Remove/Detatch items from Arrays/Objects.
143+
cJSON_DetachItemViaPointer PROTO :DWORD, :DWORD ; (cJSON *parent, cJSON * const item);
144+
cJSON_DetachItemFromArray PROTO :DWORD, :DWORD ; (cJSON *array, int which);
145+
cJSON_DeleteItemFromArray PROTO :DWORD, :DWORD ; (cJSON *array, int which);
146+
cJSON_DetachItemFromObject PROTO :DWORD, :DWORD ; (cJSON *object, const char *string);
147+
cJSON_DetachItemFromObjectCaseSensitive PROTO :DWORD, :DWORD ; (cJSON *object, const char *string);
148+
cJSON_DeleteItemFromObject PROTO :DWORD, :DWORD ; (cJSON *object, const char *string);
149+
cJSON_DeleteItemFromObjectCaseSensitive PROTO :DWORD, :DWORD ; (cJSON *object, const char *string);
150+
151+
; Update array items.
152+
cJSON_InsertItemInArray PROTO :DWORD, :DWORD, :DWORD ; (cJSON *array, int which, cJSON *newitem); Shifts pre-existing items to the right.
153+
cJSON_ReplaceItemViaPointer PROTO :DWORD, :DWORD, :DWORD ; (cJSON * const parent, cJSON * const item, cJSON * replacement);
154+
cJSON_ReplaceItemInArray PROTO :DWORD, :DWORD, :DWORD ; (cJSON *array, int which, cJSON *newitem);
155+
cJSON_ReplaceItemInObject PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object,const char *string,cJSON *newitem);
156+
cJSON_ReplaceItemInObjectCaseSensitive PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object,const char *string,cJSON *newitem);
157+
158+
159+
cJSON_Duplicate PROTO :DWORD, :DWORD ; (const cJSON *item, cJSON_bool recurse);
160+
cJSON_Compare PROTO :DWORD, :DWORD, :DWORD ; (const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
161+
cJSON_Minify PROTO :DWORD ; (char *json);
162+
163+
; Helper functions for creating and adding items to an object at the same time.
164+
; They return the added item or NULL on failure. */
165+
cJSON_AddNullToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
166+
cJSON_AddTrueToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
167+
cJSON_AddFalseToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
168+
cJSON_AddBoolToObject PROTO :DWORD,:DWORD,:DWORD ; (cJSON * const object, const char * const name, const cJSON_bool boolean);
169+
cJSON_AddNumberToObject PROTO :DWORD,:DWORD,:DWORD,:DWORD ; (cJSON * const object, const char * const name, const double number);
170+
cJSON_AddStringToObject PROTO :DWORD,:DWORD,:DWORD ; (cJSON * const object, const char * const name, const char * const string);
171+
cJSON_AddRawToObject PROTO :DWORD,:DWORD,:DWORD ; (cJSON * const object, const char * const name, const char * const raw);
172+
cJSON_AddObjectToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
173+
cJSON_AddArrayToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
174+
175+
cJSON_SetNumberHelper PROTO :DWORD,:DWORD,:DWORD ; (cJSON *object, double number);
176+
177+
cJSON_malloc PROTO :DWORD ; (size_t size);
178+
cJSON_free PROTO :DWORD ; (void *object);
179+
180+
181+
cJSON_AddObjectToArray PROTO :DWORD
182+
cJSON_AddArrayToArray PROTO :DWORD
183+
cJSON_AddNullToArray PROTO :DWORD
184+
cJSON_AddTrueToArray PROTO :DWORD
185+
cJSON_AddFalseToArray PROTO :DWORD
186+
cJSON_AddBoolToArray PROTO :DWORD, :DWORD
187+
cJSON_AddNumberToArray PROTO :DWORD, :DWORD
188+
cJSON_AddStringToArray PROTO :DWORD, :DWORD
189+
cJSON_AddRawToArray PROTO :DWORD, :DWORD
190+
191+
192+
; .CODE
193+
194+
; ; Add To Array
195+
; cJSON_AddObjectToArray PROC hJSON:DWORD
196+
; LOCAL hJSONObject:DWORD
197+
; Invoke cJSON_CreateObject
198+
; mov hJSONObject, eax
199+
; Invoke cJSON_AddItemToArray, hJSON, hJSONObject
200+
; mov eax, hJSONObject
201+
; ret
202+
; cJSON_AddObjectToArray ENDP
203+
204+
; cJSON_AddArrayToArray PROC hJSON:DWORD
205+
; LOCAL hJSONObjectArray:DWORD
206+
; Invoke cJSON_CreateArray
207+
; mov hJSONObjectArray, eax
208+
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectArray
209+
; mov eax, hJSONObjectArray
210+
; ret
211+
; cJSON_AddArrayToArray ENDP
212+
213+
; cJSON_AddNullToArray PROC hJSON:DWORD
214+
; LOCAL hJSONObjectNull:DWORD
215+
; Invoke cJSON_CreateNull
216+
; mov hJSONObjectNull, eax
217+
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectNull
218+
; mov eax, hJSONObjectNull
219+
; ret
220+
; cJSON_AddNullToArray ENDP
221+
222+
; cJSON_AddTrueToArray PROC hJSON:DWORD
223+
; LOCAL hJSONObjectTrue:DWORD
224+
; Invoke cJSON_CreateTrue
225+
; mov hJSONObjectTrue, eax
226+
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectTrue
227+
; mov eax, hJSONObjectTrue
228+
; ret
229+
; cJSON_AddTrueToArray ENDP
230+
231+
; cJSON_AddFalseToArray PROC hJSON:DWORD
232+
; LOCAL hJSONObjectFalse:DWORD
233+
; Invoke cJSON_CreateFalse
234+
; mov hJSONObjectFalse, eax
235+
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectFalse
236+
; mov eax, hJSONObjectFalse
237+
; ret
238+
; cJSON_AddFalseToArray ENDP
239+
240+
; cJSON_AddBoolToArray PROC hJSON:DWORD, dwBoolValue:DWORD
241+
; LOCAL hJSONObjectBool:DWORD
242+
; Invoke cJSON_CreateBool, dwBoolValue
243+
; mov hJSONObjectBool, eax
244+
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectBool
245+
; mov eax, hJSONObjectBool
246+
; ret
247+
; cJSON_AddBoolToArray ENDP
248+
249+
; cJSON_AddNumberToArray PROC hJSON:DWORD, dwNumberValue:DWORD
250+
; LOCAL hJSONObjectNumber:DWORD
251+
; LOCAL qwNumberValue:QWORD
252+
; mov eax, dwNumberValue
253+
; mov dword ptr [qwNumberValue+0], eax
254+
; mov dword ptr [qwNumberValue+4], eax
255+
; Invoke cJSON_CreateNumber, qwNumberValue
256+
; mov hJSONObjectNumber, eax
257+
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectNumber
258+
; mov eax, hJSONObjectNumber
259+
; ret
260+
; cJSON_AddNumberToArray ENDP
261+
262+
; cJSON_AddStringToArray PROC hJSON:DWORD, lpszString:DWORD
263+
; LOCAL hJSONObjectString:DWORD
264+
; Invoke cJSON_CreateString, lpszString
265+
; mov hJSONObjectString, eax
266+
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectString
267+
; mov eax, hJSONObjectString
268+
; ret
269+
; cJSON_AddStringToArray ENDP
270+
271+
; cJSON_AddRawToArray PROC hJSON:DWORD, lpszRawJson:DWORD
272+
; LOCAL hJSONObjectRaw:DWORD
273+
; Invoke cJSON_CreateRaw, lpszRawJson
274+
; mov hJSONObjectRaw, eax
275+
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectRaw
276+
; mov eax, hJSONObjectRaw
277+
; ret
278+
; cJSON_AddRawToArray ENDP
279+
280+
281+
282+
283+
284+
285+
286+
287+
288+
289+
290+
291+
292+
293+
294+
295+
296+
297+
298+
299+
300+
301+
302+
303+
304+

cjson_x86.lib

40.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)