| 846 | |
| 847 | |
| 848 | Try<vector<Resource>> Resources::fromString( |
| 849 | const string& text, |
| 850 | const string& defaultRole) |
| 851 | { |
| 852 | // Try to parse as a JSON Array. Otherwise, parse as a text string. |
| 853 | Try<JSON::Array> json = JSON::parse<JSON::Array>(text); |
| 854 | |
| 855 | return json.isSome() ? |
| 856 | Resources::fromJSON(json.get(), defaultRole) : |
| 857 | Resources::fromSimpleString(text, defaultRole); |
| 858 | } |
| 859 | |
| 860 | |
| 861 | Option<Error> Resources::validate(const Resource& resource) |