Home
json2vec is for predictive modeling on records that are not naturally flat. Customers have transactions, orders have line items, sessions have clickstream events, devices recur across histories, and every level can carry signal.
Most ML pipelines handle that shape by flattening it first: build rolling aggregates, hand-pick windows, maintain feature stores, and then train a model on one fixed row. That can work, but it makes representation a separate engineering system. json2vec takes the opposite path: describe the structured record, and the schema becomes the model.
The framework is designed for large production datasets, not just toy nested examples: training and batch inference over billions of observations, with throughput-oriented data paths and logging for pipelines that can process 100k+ observations per second on appropriately sized hardware. The examples in these docs stay deliberately small so the modeling loop is easy to inspect.
Core Idea
A json2vec schema is both a data contract and an architecture blueprint.
Leaf fields such as Number, Category, Set, Entity, Text, and Vector become datatype-specific tensorfields.
Branch nodes define shared contexts for child fields, with optional local attention and pooling before the representation flows upward.
Targets, masks, pruning, and embeddings are configured on the same schema tree.
Prediction output is keyed by schema address, so decoded values and embeddings remain attached to the part of the record that produced them.
That lets one model surface support supervised prediction, self-supervised reconstruction, embedding export, schema mutation, field importance, and serving without rebuilding the data representation for each workflow.
Execution Model
json2vec builds Lightning-compatible models. The schema defines the model tree, typed losses, prediction outputs, and embeddings; Lightning runs the fit, validation, test, and prediction loops, including device placement, callbacks, logging, checkpointing, and distributed execution.
A Schema Defines A Model
The generated root schema node is named record by default. This example names it order, which changes output addresses such as order/returned but does not change the source keys read from each input record.
import json2vec as jv
model = jv.Model(
d_model= 64 ,
n_layers= 2 ,
n_heads= 4 ,
embed= True ,
customer_tier= jv.Category(size= 16 ),
returned= jv.Category(target= True , size= 2 ),
line_items= jv.Branch(
embed= True ,
length= 32 ,
sku= jv.Category(size= 2048 ),
quantity= jv.Number,
price= jv.Number,
),
)
model
▶ nodes ModuleDict 780.5K ▶ record/customer_tier NodeModule 52.9K ▶ embedder Embedder 1.3K vocab OnlineVocabularyModel
▶ embeddings ModuleDict 1.3K state Embedding 5, 64 320 dtype float32device cpu
content Embedding 16, 64 1.0K dtype float32device cpu
▶ counters ModuleDict 0 state Counter
content Counter
▶ decoder Decoder 51.5K ▶ pool LearnedQueryCrossAttention 50.2K ▶ blocks ModuleList 50.0K ▶ 0 CrossAttentionBlock 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ linears ModuleDict 1.4K state Linear in_features =64, out_features =5, bias =True325 in_features 64
out_features 5
bias True
tensor
dtype float32
device cpu
content Linear in_features =64, out_features =16, bias =True1.0K in_features 64
out_features 16
bias True
tensor
dtype float32
device cpu
▶ record/returned NodeModule 51.1K ▶ embedder Embedder 448 vocab OnlineVocabularyModel
▶ embeddings ModuleDict 448 state Embedding 5, 64 320 dtype float32device cpu
content Embedding 2, 64 128 dtype float32device cpu
▶ counters ModuleDict 0 state Counter
content Counter
▶ decoder Decoder 50.6K ▶ pool LearnedQueryCrossAttention 50.2K ▶ blocks ModuleList 50.0K ▶ 0 CrossAttentionBlock 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ linears ModuleDict 455 state Linear in_features =64, out_features =5, bias =True325 in_features 64
out_features 5
bias True
tensor
dtype float32
device cpu
content Linear in_features =64, out_features =2, bias =True130 in_features 64
out_features 2
bias True
tensor
dtype float32
device cpu
▶ record/line_items/sku NodeModule 317.0K ▶ embedder Embedder 131.4K vocab OnlineVocabularyModel
▶ embeddings ModuleDict 131.4K state Embedding 5, 64 320 dtype float32device cpu
content Embedding 2048, 64 131.1K dtype float32device cpu
▶ counters ModuleDict 0 state Counter
content Counter
▶ decoder Decoder 185.6K ▶ pool LearnedQueryCrossAttention 52.2K ▶ blocks ModuleList 50.0K ▶ 0 CrossAttentionBlock 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ linears ModuleDict 133.4K state Linear in_features =64, out_features =5, bias =True325 in_features 64
out_features 5
bias True
tensor
dtype float32
device cpu
content Linear in_features =64, out_features =2048, bias =True133.1K in_features 64
out_features 2048
bias True
tensor
dtype float32
device cpu
▶ record/line_items/quantity NodeModule 54.6K ▶ embedder Embedder 2.0K embeddings Embedding 5, 64 320 dtype float32device cpu
counter Counter
linear Linear in_features =26, out_features =64, bias =True1.7K in_features 26
out_features 64
bias True
tensor
dtype float32
device cpu
normalizer GlobalOnlineNormalizer
▶ decoder Decoder 52.6K ▶ pool LearnedQueryCrossAttention 52.2K ▶ blocks ModuleList 50.0K ▶ 0 CrossAttentionBlock 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
classification Linear in_features =64, out_features =5, bias =True325 in_features 64
out_features 5
bias True
tensor
dtype float32
device cpu
regression Linear in_features =64, out_features =1, bias =True65 in_features 64
out_features 1
bias True
tensor
dtype float32
device cpu
▶ record/line_items/price NodeModule 54.6K ▶ embedder Embedder 2.0K embeddings Embedding 5, 64 320 dtype float32device cpu
counter Counter
linear Linear in_features =26, out_features =64, bias =True1.7K in_features 26
out_features 64
bias True
tensor
dtype float32
device cpu
normalizer GlobalOnlineNormalizer
▶ decoder Decoder 52.6K ▶ pool LearnedQueryCrossAttention 52.2K ▶ blocks ModuleList 50.0K ▶ 0 CrossAttentionBlock 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
classification Linear in_features =64, out_features =5, bias =True325 in_features 64
out_features 5
bias True
tensor
dtype float32
device cpu
regression Linear in_features =64, out_features =1, bias =True65 in_features 64
out_features 1
bias True
tensor
dtype float32
device cpu
▶ record NodeModule 150.1K ▶ encoder BranchEncoder 150.1K ▶ encoder ModuleList 100.0K ▶ 0 RotaryTransformerEncoderLayer 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
▶ 1 RotaryTransformerEncoderLayer 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
▶ pool LearnedQueryCrossAttention 50.2K ▶ blocks ModuleList 50.0K ▶ 0 CrossAttentionBlock 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ record/line_items NodeModule 100.2K ▶ encoder BranchEncoder 100.2K ▶ encoder ModuleList 50.0K ▶ 0 RotaryTransformerEncoderLayer 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
▶ pool LearnedQueryCrossAttention 50.2K ▶ blocks ModuleList 50.0K ▶ 0 CrossAttentionBlock 50.0K attention_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
ffn_norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
▶ attention RotaryMultiheadAttention 16.6K q_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
k_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
v_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
out_proj Linear in_features =64, out_features =64, bias =True4.2K in_features 64
out_features 64
bias True
tensor
dtype float32
device cpu
rotary RotaryEmbedding
▶ ffn Sequential 33.1K 0 Linear in_features =64, out_features =256, bias =True16.6K in_features 64
out_features 256
bias True
tensor
dtype float32
device cpu
1 GELU approximate ='none'approximate 'none'
2 Dropout p =0.0, inplace =Falsep 0.0inplace False
3 Linear in_features =256, out_features =64, bias =True16.4K in_features 256
out_features 64
bias True
tensor
dtype float32
device cpu
4 Dropout p =0.0, inplace =Falsep 0.0inplace False
norm LayerNorm (64,) eps =1e-05, elementwise_affine =True, bias =True128 eps 1e-05
elementwise_affine True
bias True
tensor
dtype float32
device cpu
This model reads records shaped like:
{
"customer_tier" : "gold" ,
"line_items" : [
{"sku" : "A12" , "quantity" : 2 , "price" : 19.99 },
{"sku" : "B07" , "quantity" : 1 , "price" : 45.50 },
],
"returned" : "false" ,
}
{"customer_tier": "gold", "line_items": [{"sku": "A12", "quantity": 2, "price": "text/plain+float:19.99"}, {"sku": "B07", "quantity": 1, "price": "text/plain+float:45.5"}], "returned": "false"}
The model learns from the order as a structured object. The line_items branch has its own repeated context, returned is withheld and decoded as a supervised target, and embed=True asks prediction to emit embeddings at configured addresses.
What Is Different
Hierarchical context encoding: child records interact locally before their representation flows upward. A login session, transaction list, or order item list can keep its own window instead of competing inside one flat sequence.
Extensible datatypes: each field type owns validation, tensorization, missing-state handling, masking, decoding, loss, metrics, and output writing.
Unified training roles: target=True, p_prune, and p_mask all use the same reconstruction path, so supervised and self-supervised objectives share the model tree.
Embedding trees: embeddings can come from the root, branches, or selected leaves, making branch-level retrieval and diagnostics possible.
Schema evolution: models are completely mutable and can be updated, extended, deleted, reset, or temporarily overridden after construction.
Scale-oriented runtime: online preprocessing state, streaming data modules, throughput logging, and checkpointed tensorfield state are designed for high-volume training and prediction jobs.
One path for training and serving: queries, preprocessors, tensorization, model execution, prediction writing, and postprocessors stay in the same configured path.
When It Fits
Use json2vec when relationships inside the record matter: account histories, fraud or risk snapshots, order and fulfillment events, flight itineraries, operations telemetry, user sessions, repeated measurements, or any mixed datatype object where flattening would discard useful structure.
Use a simpler tabular model when flattening loses no meaningful context. The point is not to replace every table. The point is to model nested business data without making a feature table the only representation the model can see.