MCPcopy Create free account
hub / github.com/KingOfBugbounty/enumrust / parse_json_objects_from_content

Function parse_json_objects_from_content

src/main.rs:3307–3343  ·  view source on GitHub ↗

Parse JSON outputs in object-per-line or full JSON formats and return JSON objects.

(content: &str)

Source from the content-addressed store, hash-verified

3305
3306/// Parse JSON outputs in object-per-line or full JSON formats and return JSON objects.
3307fn parse_json_objects_from_content(content: &str) -> Vec<serde_json::Value> {
3308 let trimmed = content.trim();
3309 if trimmed.is_empty() {
3310 return Vec::new();
3311 }
3312
3313 let mut out = Vec::new();
3314
3315 if let Ok(value) = serde_json::from_str::<serde_json::Value>(trimmed) {
3316 match value {
3317 serde_json::Value::Array(items) => {
3318 out.extend(items.into_iter().filter(|item| item.is_object()));
3319 return out;
3320 }
3321 serde_json::Value::Object(_) => {
3322 out.push(value);
3323 return out;
3324 }
3325 _ => {}
3326 }
3327 }
3328
3329 for line in content.lines() {
3330 let line = line.trim();
3331 if line.is_empty() {
3332 continue;
3333 }
3334
3335 if let Ok(value) = serde_json::from_str::<serde_json::Value>(line) {
3336 if value.is_object() {
3337 out.push(value);
3338 }
3339 }
3340 }
3341
3342 out
3343}
3344
3345/// Parse FFUF output in JSON or NDJSON variants and extract discovered URLs.
3346fn extract_ffuf_urls(content: &str) -> Vec<String> {

Calls

no outgoing calls