Commit graph

2 commits

Author SHA1 Message Date
Martin Stjernholm
37fa32ce94 Output json without trailing whitespaces but with trailing newlines.
Makes them more editor friendly, primarily when copied into
system/linkerconfig/testdata/root.

Test: m
Test: No diff between apex_manifest_full.json in out/
  and in linkerconfig/testdata/root/
Bug: 140599044
Change-Id: I6dacdd4baa59e6d70586c4a6343b9b8fd1b574f6
2020-02-24 22:20:49 +00:00
Jooyung Han
04329f131a Add jsonmodify tool
This tool is used to modify apex_manifest.json when building apex
module.

Here's the usage:

usage: jsonmodify [-h] [-o output] [-v path value] [-s path value]
                     [-r path] [-a path [value ...]]
                     [input]

positional arguments:
  input                 JSON file

optional arguments:
  -h, --help            show this help message and exit
  -o output, --out output
                        write result to a file. If omitted, print to stdout
  -v path value, --value path value
                        set value of the key specified by path. If path
                        doesn't exist, creates new one.
  -s path value, --replace path value
                        replace value of the key specified by path. If path
                        doesn't exist, no op.
  -r path, --remove path
                        remove the key specified by path. If path doesn't
                        exist, no op.
  -a path [value ...], --append_list path [value ...]
                        append values to the list specified by path. If path
                        doesn't exist, creates new list for it.

Bug: 138695532
Test: m jsonmodify
Test: echo {} | jsonmodify -v name hello -a list.nested a b c
{
  "name": "hello",
  "list": {
    "nested": [
      "a",
      "b",
      "c"
    ]
  }
}

Change-Id: I2cd043c614b3ad2306a0c27ccee302633c6d2525
2019-08-02 00:08:05 +09:00