util/spd_tools: Support comments in json

Allow comments in json file for better documentation. Comments must be
on seperate line.

BUG=none
TEST=Injest global_ddr4_mem_parts.json.txt with comments

Change-Id: I51295408d4f916708e4ed5bc42d5468ccdc68a6b
Signed-off-by: Rob Barnes <robbarnes@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/44834
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Rob Barnes 2020-08-26 09:56:37 -06:00 committed by Furquan Shaikh
parent 196e9c0021
commit a2e431331c
2 changed files with 8 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import (
"reflect"
"strconv"
"strings"
"regexp"
)
/*
@ -998,6 +999,10 @@ func readMemoryParts(memParts *memParts, memPartsFileName string) error {
return err
}
// Strip comments from json file
re := regexp.MustCompile(`(?m)^\s*//.*`)
databytes = re.ReplaceAll(databytes, []byte(""))
return json.Unmarshal(databytes, memParts)
}

View File

@ -1,3 +1,6 @@
// Global list of ddr4 memory part attributes.
// These attributes match the part specifications and are independent
// of any SoC expectations.
{
"parts": [
{