enable string syntax for the filters

This commit is contained in:
Marin Postma 2021-05-04 18:22:48 +02:00
parent a717925caa
commit b192cb9c1f
No known key found for this signature in database
GPG key ID: D5241F0C0C865F30
2 changed files with 37 additions and 32 deletions

View file

@ -2,6 +2,7 @@ use std::collections::HashSet;
use std::convert::{TryFrom, TryInto};
use actix_web::{get, post, web, HttpResponse};
use serde_json::Value;
use serde::Deserialize;
use crate::error::ResponseError;
@ -50,7 +51,12 @@ impl TryFrom<SearchQueryGet> for SearchQuery {
.map(|attrs| attrs.split(',').map(String::from).collect::<Vec<_>>());
let filter = match other.filter {
Some(ref f) => Some(serde_json::from_str(f)?),
Some(f) => {
match serde_json::from_str(&f) {
Ok(v) => Some(v),
_ => Some(Value::String(f)),
}
},
None => None,
};