Skip to content

add cli option --detailed-result-json to print results in JSON #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 12, 2025

Conversation

dilawar
Copy link
Contributor

@dilawar dilawar commented Jun 21, 2025

Close #64. User can now pass --detailed-results-json to print the results in JSON format.

  • Adds a dependency serde_json !
  • Changes code formatting at a few places because I ran cargo +nightly fmt. I can revert them back. These changes are both harmless and useless.

The prefix Detection result: \n is not printed when --detailed-results-json is used. It is to ensure that if another process captures stdout at a successful run, it can assume it to be a valid JSON.

image

Example run

Running `/home/dilawar/rxing/target/debug/rxing-cli /home/dilawar/Downloads/3298.png decode --detailed-results-json`
{
  "text": "https://ehr-sample.onrender.com/sample/0003298",
  "rawBytes": [
    104,
    116,
    116,
    112,
    115,
    58,
    47,
    47,
    101,
    104,
    114,
    45,
    115,
    97,
    109,
    112,
    108,
    101,
    46,
    111,
    110,
    114,
    101,
    110,
    100,
    101,
    114,
    46,
    99,
    111,
    109,
    47,
    115,
    97,
    109,
    112,
    108,
    101,
    47,
    48,
    48,
    48,
    51,
    50,
    57,
    56
  ],
  "numBits": 368,
  "resultPoints": [
    {
      "x": 14.202776,
      "y": 14.20277
    },
    {
      "x": 255.11395,
      "y": 14.079432
    },
    {
      "x": 254.94168,
      "y": 254.94171
    },
    {
      "x": 14.079441,
      "y": 255.11395
    }
  ],
  "format": "QR_CODE",
  "resultMetadata": {
    "ERROR_CORRECTION_LEVEL": {
      "ErrorCorrectionLevel": "L"
    },
    "STRUCTURED_APPEND_SEQUENCE": {
      "StructuredAppendSequence": -1
    },
    "SYMBOLOGY_IDENTIFIER": {
      "SymbologyIdentifier": "]Q1"
    },
    "STRUCTURED_APPEND_PARITY": {
      "StructuredAppendParity": -1
    }
  },
  "timestamp": 1750522910447,
  "line_count": 0
}

@hschimke hschimke merged commit c48d192 into rxing-core:main Jul 12, 2025
1 check passed
@dilawar dilawar deleted the issue-64-add-json branch July 12, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider emitting scan results in JSON/XML?
2 participants