JSON中变量变量的格式?

时间:2018-08-02 17:43:05

标签: json

只是开始从文本头文件移动到各种传感器的jsons。这是许多中的第一个。

我创建了一个描述二进制数据文件结构的json。 基本格式为:varName:[startByte,长度,“数据类型”,“描述”]。 但是,某些startByte值取决于早期的变量。因此,“变量”。也许有一个名词?

在下面json的底部附近,有一些var,其startByte类似于var:Obj.var 我将解析它们,从数据文件中读取值,并按照指示的数学方法得出实际值。

虽然可行,但似乎其他人以前可能已经处理过。还有更标准的解决方案吗?这样的变量有术语吗?

{
  "Meta": {
    "Source": "ASD File Format version 8 rev B",
    "Format": ["Start byte", "Length in bytes", "Datatype", "Description" ],
    "Datatypes": "Float and integer follows the pattern [u][int|flt]NumberOfBytes.  Ex: a long would be int8. Other types, all are 1 byte: str (string), pad (padding), oct, hex, bool, and unk (unknown)."
  },

  "Header": { 
    "co":               [ 0,     3,    "str", "File Version - as6" ],
    "comments":         [ 3,   157,    "str", "Comments" ],
    "when":             [ 160,  18,  "uint2", "Time when spectrum was saved. Sec, min, hour, mday, mon (0-11), year, wday, yday, isDST" ],
    "program_version":  [ 178,   1,  "uint1", "Major in upper nibble, minor in lower" ],
    "file_version":     [ 179,   1,  "uint1", "Spectrum file format version" ],
    "itime":            [ 180,   1,  "uint1", "Not used after v2.00" ],
    "dc_corr":          [ 181,   1,  "uint1", "1 if DC subtracted, 0 if not" ],
    "dc_time":          [ 182,   4,  "uint4", "Time of last dc, seconds since 1970.01.01" ],
    "data_type":        [ 186,   1,  "uint1", "0=RAW, 1=REF, 2=RAD, 3=NOUNITS" ],
    "ref_time":         [ 187,   4,  "uint4", "Time of last wr, seconds since 1970.01.01" ],
    "ch1_wavel":        [ 191,   4,   "flt4", "Calibrated starting waveleng (nm)" ],
    "wavel_step":       [ 195,   4,   "flt4", "Calibrated wavelength step (nm)" ],
    "data_format":      [ 199,   1,  "uint1", "Format of spectrum" ],
    "old_dc_count":     [ 200,   1,  "uint1", "Num of DC measurements in the avg" ],
    "old_ref_count":    [ 201,   1,  "uint1", "Num or WR in the average" ],
    "old_sample_count": [ 202,   1,  "uint1", "Num of spec samples in the avg" ],
    "application":      [ 203,   1,  "uint1", "Which application created the APP_DATA" ],
    "channels":         [ 204,   2,  "uint2", "Num of channels in the detector" ],
    "app_data":         [ 206, 128,    "unk", "Application specific data. No further info available." ],
    "gps_data":         [ 334,  56,    "unk", "GPS position, course, etc. Possible error in manual. 58B described, but only 56B available." ],
    "it":               [ 390,   4,  "uint4", "Actual integration time in mS." ],
    "fo":               [ 394,   2,  "uint2", "The fo attachment's view in degrees." ],
    "dcc":              [ 396,   2,  "uint2", "Dark current corretion value." ],
    "calibration":      [ 398,   2,  "uint2", "Calibration series." ],
    "instrument_num":   [ 400,   2,  "uint2", "Instrument number." ],
    "ymin":             [ 402,   4,   "flt4", "Setting of the y axis min value." ],
    "ymax":             [ 406,   4,   "flt4", "Setting of the y axis max value." ],
    "xmin":             [ 410,   4,   "flt4", "Setting of the x axis min value." ],
    "xmax":             [ 414,   4,   "flt4", "Setting of the x axis max value." ],
    "ip_numbits":       [ 418,   2,  "uint2", "Instrument dynamic range." ],
    "xmode":            [ 420,   1,  "uint1", "X axis mode." ],
    "flags":            [ 421,   4,  "uint1", "Flags[0]=AVGFIX'ed, Flags[1]: vnir saturation=1, swir1 saturation=2, swir2 saturation=3, Tec1 alarm=8, Tec2 alarm=16." ],
    "dc_count":         [ 425,   2,  "uint2", "Num of DC measurements in the avg." ],
    "ref_count":        [ 427,   2,  "uint2", "Num of WR in the average." ],
    "sample_count":     [ 429,   2,  "uint2", "Num of spec samples in the avg." ],
    "instrument":       [ 431,   1,  "uint1", "Instrument type. Byte 0=Unknown, 1=PSII, 2=LSVNIR, 3=FSVNIR, 4=FSFR, 5=FSNIR, 6=CHEM, 7=FSFR_unattended." ],
    "bulb":             [ 432,   4,  "uint4", "ID number of the cal bulb." ],
    "swir1_gain":       [ 436,   2,  "uint2", "Gain setting for swir 1." ],
    "swir2_gain":       [ 438,   2,  "uint2", "Gain setting for swir 2." ],
    "swir1_offset":     [ 440,   2,  "uint2", "Offset for swir 1." ],
    "swir2_offset":     [ 442,   2,  "uint2", "Offset for swir 2." ],
    "splice1_wavelength": [ 444, 4,   "flt4", "Wavelength of VNIR and SWIR1 splice." ],
    "splice2_wavelength": [ 448, 4,   "flt4", "Wavelength of SWIR1 and SWIR2 splice." ],
    "SmartDetectorType":  [ 452, 27,  "flt4", "Data for OL731 device." ],
    "spare":            [ 479,   5,    "pad", "Fill to 484 bytes."]
  },

  "SpectrumData": { 
    "Spectrum": [ 485, "var:Header.channels", "flt8", "Spectrum data to size of channels." ]
  },

  "ReferenceFileHeader": {  
    "meta": {
        "position": "var:SpectrumData.Spectrum[1] + 1",
        "size": "unk",
        "end": "var:ReferenceFileHeader.meta.position + ReferenceFileHeader.meta.size + 1"
    },
    "ReferenceFlag": [ "var:meta.end + 1", 2, "bool", "Reference been taken." ],
    "ReferenceTime": [ "var:meta.end + 1 + 3", 8,  "date", "Time reference was taken." ],
    "SpectrumTime": [ "var:meta.end + 1 + 11", 8, "date", "Time spectrum was taken." ],
    "SpectrumDescription": [ "var:meta.end + 1 + 19", "var", "str", "Description of spectrum."]
  }

}

0 个答案:

没有答案