@@ -640,10 +640,11 @@ ColumnEncoder::colVec ColumnEncoder::columnNamesEncoded()
640
640
641
641
void ColumnEncoder::_convertPreloadingDataOption (Json::Value & options, const std::string& optionName, colsPlusTypes& colTypes)
642
642
{
643
- Json::Value newOption = Json::arrayValue,
644
- typeList = options[optionName][" types" ],
645
- valueList = options[optionName][" value" ];
646
643
std::string optionKey = options[optionName].isMember (" optionKey" ) ? options[optionName][" optionKey" ].asString () : " " ;
644
+ bool keepOriginalOption = (!optionKey.empty () && options[optionName].size () > 3 ); // The option has other members: this must be kept
645
+ Json::Value typeList = options[optionName][" types" ],
646
+ valueList = options[optionName][" value" ],
647
+ newOption = keepOriginalOption ? options[optionName] : Json::arrayValue;
647
648
648
649
bool useSingleVal = false ;
649
650
@@ -662,6 +663,9 @@ void ColumnEncoder::_convertPreloadingDataOption(Json::Value & options, const st
662
663
typeList.append (type);
663
664
}
664
665
666
+ if (keepOriginalOption)
667
+ newOption[optionKey] = Json::arrayValue;
668
+
665
669
// The valueList can be either;
666
670
// . a list of strings, if it is a list of variables without interaction
667
671
// . a list of array of strings if it is a list of variables with interaction
@@ -673,7 +677,7 @@ void ColumnEncoder::_convertPreloadingDataOption(Json::Value & options, const st
673
677
{
674
678
Json::Value jsonType = typeList.size () > i ? typeList[i] : Json::nullValue,
675
679
jsonValueOrg = valueList[i],
676
- jsonValue = optionKey.empty () ? jsonValueOrg : jsonValueOrg[optionKey];
680
+ jsonValue = ( optionKey.empty () || keepOriginalOption || !jsonValueOrg. isMember (optionKey) ) ? jsonValueOrg : jsonValueOrg[optionKey];
677
681
678
682
if (jsonValue.isString ())
679
683
{
@@ -691,6 +695,8 @@ void ColumnEncoder::_convertPreloadingDataOption(Json::Value & options, const st
691
695
692
696
if (optionKey.empty ())
693
697
newOption.append (columnNameWithType);
698
+ else if (keepOriginalOption)
699
+ newOption[optionKey].append (columnNameWithType);
694
700
else
695
701
{
696
702
// Reuse original jsonValue in order to get the other members of the object
@@ -727,6 +733,8 @@ void ColumnEncoder::_convertPreloadingDataOption(Json::Value & options, const st
727
733
}
728
734
if (optionKey.empty ())
729
735
newOption.append (newColumnNames);
736
+ else if (keepOriginalOption)
737
+ newOption[optionKey].append (newColumnNames);
730
738
else
731
739
{
732
740
jsonValueOrg[optionKey] = newColumnNames;
@@ -751,10 +759,15 @@ void ColumnEncoder::_addTypeToColumnNamesInOptionsRecursively(Json::Value & opti
751
759
{
752
760
if (preloadingData)
753
761
_convertPreloadingDataOption (options, optionName, colTypes);
754
- else // make sure "optionnam e ".types is available for analyses incapable of preloadingData, this should be considered deprecated
762
+ else // make sure "optionname ".types is available for analyses incapable of preloadingData, this should be considered deprecated
755
763
{
756
764
options[optionName + " .types" ] = options[optionName][" types" ];
757
- options[optionName] = options[optionName][" value" ];
765
+
766
+ std::string optionKey = options[optionName].isMember (" optionKey" ) ? options[optionName][" optionKey" ].asString () : " " ;
767
+ bool keepOriginalOption = (!optionKey.empty () && options[optionName].size () > 3 ); // The option has other members: this must be kept
768
+
769
+ if (!keepOriginalOption)
770
+ options[optionName] = options[optionName][" value" ];
758
771
}
759
772
}
760
773
else
0 commit comments