@@ -47,7 +47,7 @@ feature -- Post
47
47
end
48
48
end
49
49
50
- feature -- Get
50
+ feature -- Get
51
51
52
52
get_from_id (a_spreadsheet_id : STRING_ 8 ; a_params : detachable EG_SPREADSHEET_PARAMETERS ): detachable EG_SPREADSHEET
53
53
note
@@ -299,17 +299,19 @@ feature {NONE} -- JSON To Eiffel
299
299
-- Create an object `EG_COLOR` from a json rerpesentation `a_json`.
300
300
do
301
301
create Result
302
- if attached real_value_from_json (a_json , " red" ) as l_val then
303
- Result .set_red (l_val )
304
- end
305
- if attached real_value_from_json (a_json , " green" ) as l_val then
306
- Result .set_green (l_val )
307
- end
308
- if attached real_value_from_json (a_json , " blue" ) as l_val then
309
- Result .set_blue (l_val )
310
- end
311
- if attached real_value_from_json (a_json , " alpha" ) as l_val then
312
- Result .set_alpha (l_val )
302
+ if not a_json .is_empty then
303
+ if attached color_value_from_json (a_json , " red" ) as l_val then
304
+ Result .set_red (l_val )
305
+ end
306
+ if attached color_value_from_json (a_json , " green" ) as l_val then
307
+ Result .set_green (l_val )
308
+ end
309
+ if attached color_value_from_json (a_json , " blue" ) as l_val then
310
+ Result .set_blue (l_val )
311
+ end
312
+ if attached color_value_from_json (a_json , " alpha" ) as l_val then
313
+ Result .set_alpha (l_val )
314
+ end
313
315
end
314
316
end
315
317
@@ -404,7 +406,9 @@ feature {NONE} -- JSON To Eiffel
404
406
Result .set_properties (sheet_properties (l_properties ))
405
407
end
406
408
if attached {JSON_ARRAY } json_value (a_json , " data" ) as l_data then
407
- -- TODO
409
+ across l_data as ic loop
410
+ Result .force_data (eg_data_grid (ic .item ))
411
+ end
408
412
end
409
413
if attached {JSON_ARRAY } json_value (a_json , " merges" ) as l_merges then
410
414
-- TODO
@@ -441,6 +445,41 @@ feature {NONE} -- JSON To Eiffel
441
445
end
442
446
end
443
447
448
+ eg_data_grid (a_json : JSON_VALUE ): EG_GRID_DATA
449
+ -- Create an object `EG_GRID_DATA` from a json representation.
450
+ do
451
+ create Result
452
+ if attached integer_value_from_json (a_json , " startRow" ) as l_val then
453
+ Result .set_start_row (l_val )
454
+ end
455
+ if attached integer_value_from_json (a_json , " startColumn" ) as l_val then
456
+ Result .set_start_column (l_val )
457
+ end
458
+ if attached {JSON_ARRAY } json_value (a_json , " rowData" ) as l_data then
459
+ across l_data as ic loop
460
+ Result .force_row_data (eg_row_data (ic .item ))
461
+ end
462
+ end
463
+ end
464
+
465
+ eg_row_data (a_json : JSON_VALUE ): EG_ROW_DATA
466
+ -- Create an object `EG_ROW_DATA` from a json representation.
467
+ do
468
+ create Result
469
+ if attached {JSON_ARRAY } json_value (a_json , " values" ) as l_data then
470
+ across l_data as ic loop
471
+ Result .force_value (eg_cell_data (ic .item ))
472
+ end
473
+ end
474
+ end
475
+
476
+ eg_cell_data (a_json : JSON_VALUE ): EG_CELL_DATA
477
+ -- Create an object `EG_CELL_DATA` from a json representation.
478
+ do
479
+ create Result
480
+
481
+ end
482
+
444
483
eg_named_ranges (a_json : JSON_VALUE ): EG_NAMED_RANGE
445
484
-- Create an object `EG_NAMED_RANGE` from a json representation.
446
485
do
@@ -458,6 +497,9 @@ feature {NONE} -- JSON To Eiffel
458
497
459
498
sheet_properties (a_json : JSON_VALUE ): EG_SHEET_PROPERTIES
460
499
-- Create an object `EG_SHEET_PROPERTIES` from a json representation `a_json`.
500
+ local
501
+ l_stype : EG_SHEET_TYPE
502
+ l_grid_prop : EG_GRID_PROPERTIES
461
503
do
462
504
create Result
463
505
if attached integer_value_from_json (a_json , " sheetId" ) as l_sheetId then
@@ -470,19 +512,23 @@ feature {NONE} -- JSON To Eiffel
470
512
Result .set_index (l_index )
471
513
end
472
514
if attached string_value_from_json (a_json , " sheetType" ) as l_sheet_type then
515
+ create l_stype
473
516
if l_sheet_type .is_case_insensitive_equal (" GRID" ) then
474
- Result . sheet_type .set_grid
517
+ l_stype .set_grid
475
518
elseif l_sheet_type .is_case_insensitive_equal (" OBJECT" ) then
476
- Result . sheet_type .set_grid
519
+ l_stype .set_grid
477
520
end
521
+ Result .set_sheet_type (l_stype )
478
522
end
479
523
if attached {JSON_OBJECT } json_value (a_json , " gridProperties" ) as l_grid_properties then
524
+ create l_grid_prop
480
525
if attached integer_value_from_json (l_grid_properties , " rowCount" ) as l_row_count then
481
- Result . grid_properties .set_row_count (l_row_count )
526
+ l_grid_prop .set_row_count (l_row_count )
482
527
end
483
528
if attached integer_value_from_json (l_grid_properties , " columnCount" ) as l_column_count then
484
- Result . grid_properties .set_column_count (l_column_count )
529
+ l_grid_prop .set_column_count (l_column_count )
485
530
end
531
+ Result .set_grid_properties (l_grid_prop )
486
532
end
487
533
if attached boolean_value_from_json (a_json , " hidden" ) as l_hidden then
488
534
Result .set_hidden (l_hidden )
@@ -638,6 +684,21 @@ feature {NONE} -- Implementation
638
684
end
639
685
end
640
686
687
+ color_value_from_json (a_json_data : detachable JSON_VALUE ; a_id : STRING ): REAL
688
+ do
689
+ if
690
+ attached {JSON_NUMBER } json_value (a_json_data , a_id ) as v and then
691
+ v .numeric_type = v .real_type
692
+ then
693
+ Result := v .item .to_real
694
+ elseif attached {JSON_NUMBER } json_value (a_json_data , a_id ) as v and then
695
+ v .numeric_type = v .integer_type
696
+ then
697
+ Result := v .item .to_integer
698
+ end
699
+
700
+ end
701
+
641
702
integer_value_from_json (a_json_data : detachable JSON_VALUE ; a_id : STRING ): INTEGER
642
703
do
643
704
if
0 commit comments