[POSTPONED] Filter for JSON properties using JSON queries

Hi there,

Is it possible to use the OData $filter to query on JSON properties? For example we have the following data on a content item.

"Frameworks": {
	"iv": [{
		"id": "d7fa3237-4947-45c1-92e8-0efa7637ad80",
		"title": "Activity Hours",
		"framework": "v.1 - HSUK2020: Top 25 priorities",
		"frameworkId": "93fe67e7-8a98-4752-956f-6a65c0447c82"
	}]
}	

Is it possible to use this query;

$filter=(contains(data/Frameworks/iv/title,%20%27Activity%20Hours%27)

Currently I receive the response “Could not find a property named ‘Frameworks’ on type ‘Ipm.Resource.Data’.”

Any help would be appreciated.

Unfortunately not. Odata is type safe and does not understand dynamic types. You could try to use JSON queries.

Thanks Sebastian,

Just trying to get this to work. I tried using;

q = {
	top: 10,
	skip: 0,
	orderBy: 'created desc',
	filter: {
		{
			path: 'data.Frameworks.iv.title',
			op: 'eq',
			value: 'Activity Hours'
		}
	}
}

But it failed with the message “Path ‘data.Frameworks.iv.title’ does not point to a valid property in the model.”.

I then tried this;

q = {
	top: 10,
	skip: 0,
	orderBy: 'created desc',
	filter: {
		{
			path: 'data.Frameworks.iv',
			op: 'contains',
			value: 'Activity Hours'
		}
	}
}

And received 0 results. Any ideas?

Then it does not work yet. I can change this to a feature request.

Awesome, thank you. Love the product by the way, great work!

1 Like

Hi, I was digging into this. The problem is that JSON fields are encoded before saving them to the database, because not all JSON structures are compatible with MongoDB.

Therefore it is right now not possible to implement that.