@@ -196,7 +196,8 @@ public virtual JToken Compact(Context activeCtx, string activeProperty, JToken e
196196 if ( ! ( result [ property ] is JArray ) )
197197 {
198198 JArray tmp = new JArray ( ) ;
199- tmp . Add ( result [ property ] = tmp ) ;
199+ tmp . Add ( result [ property ] ) ;
200+ result [ property ] = tmp ;
200201 }
201202 if ( value is JArray )
202203 {
@@ -356,7 +357,8 @@ public virtual JToken Compact(Context activeCtx, string activeProperty, JToken e
356357 if ( ! ( mapObject [ mapKey ] is JArray ) )
357358 {
358359 tmp = new JArray ( ) ;
359- tmp . Add ( mapObject [ mapKey ] = tmp ) ;
360+ tmp . Add ( mapObject [ mapKey ] ) ;
361+ mapObject [ mapKey ] = tmp ;
360362 }
361363 else
362364 {
@@ -388,7 +390,8 @@ public virtual JToken Compact(Context activeCtx, string activeProperty, JToken e
388390 if ( ! ( result [ itemActiveProperty ] is JArray ) )
389391 {
390392 JArray tmp = new JArray ( ) ;
391- tmp . Add ( result [ itemActiveProperty ] = tmp ) ;
393+ tmp . Add ( result [ itemActiveProperty ] ) ;
394+ result [ itemActiveProperty ] = tmp ;
392395 }
393396 if ( compactedItem is JArray )
394397 {
@@ -763,7 +766,7 @@ public virtual JToken Expand(Context activeCtx, string activeProperty, JToken el
763766 else
764767 {
765768 // 7.5
766- if ( "@language" . Equals ( activeCtx . GetContainer ( key ) ) && value is IDictionary )
769+ if ( "@language" . Equals ( activeCtx . GetContainer ( key ) ) && value is JObject )
767770 {
768771 // 7.5.1)
769772 expandedValue = new JArray ( ) ;
@@ -1088,7 +1091,8 @@ internal virtual void GenerateNodeMap(JToken element, JObject
10881091 }
10891092 JObject graph = ( JObject ) nodeMap [ activeGraph
10901093 ] ;
1091- JObject node = ( JObject ) ( activeSubject . IsNull ( ) ? null : graph [ ( string ) activeSubject ] ) ;
1094+ JObject node = ( JObject ) ( ( activeSubject . IsNull ( ) || activeSubject . Type != JTokenType . String )
1095+ ? null : graph [ ( string ) activeSubject ] ) ;
10921096 // 3)
10931097 if ( elem . ContainsKey ( "@type" ) )
10941098 {
@@ -1715,7 +1719,7 @@ private bool FilterNode(JsonLdApi.FramingContext state, JObject node, JObject fr
17151719 ) ;
17161720 }
17171721 }
1718- if ( ( ( JArray ) types ) . Count == 1 && ( ( JArray ) types ) [ 0 ] is IDictionary
1722+ if ( ( ( JArray ) types ) . Count == 1 && ( ( JArray ) types ) [ 0 ] is JObject
17191723 && ( ( JObject ) ( ( JArray ) types ) [ 0 ] ) . Count == 0 )
17201724 {
17211725 return ! ( ( JArray ) nodeTypes ) . IsEmpty ( ) ;
0 commit comments