2 svar
144 visningar
TB16 behöver inte mer hjälp
TB16 182 – Fd. Medlem
Postad: 24 aug 2019 14:16

Encode the example log in a JSON document

Uppgift:

In this task you will store a log for a meteorological measuring station. The log keeps tracks
of two kinds of data: Performed measurements, and requests for information from users.
Here is an example of a log in plain text, containing a single measurement and a single
request:

Measurement time=1560000000,
temperature=21,
windspeed=0,
rainfall=Error 213 no value found

User Jonas requested temperature, rainfall
replied with time=1560000000,
temperature=21,
rainfall=Error 213 no value found

A measurement always contains a timestamp, and values for a number of additional
parameters, in the example above the additional parameters are temperature, windspeed and
rainfall, but they can be any set of text strings. The values are either numbers or errors.
Errors contain an error code (213 in the example) and an error text (“no value found” in the
example). The order of parameters (including time) is not important. The number and names
of parameters can differ between measurements in the log.
A user request contains a username and a list of parameters (order not important). It also
contains a reply consisting of parameters and values/errors (note the similarity to
measurements). You may assume that replies always contain a time parameter. Your schema
does NOT have to enforce that the reply contains all the requested parameters or that values
are correct in context.
Each whole log should be a single JSON document containing multiple measurements and
served requests (order is important). Each entry must be either a measurement or a request.

a) Encode the example log above in a JSON document.
Regarding syntax: Missing a few quotation marks is not a big deal, but make sure the
structure and what type of JSON elements you are using is clear.

Jag försökte lösa uppgiften på följande vis:
Svaret till uppgiften:
Fråga 1:
Hur kommer det sig att measurement är ett objekt av enbart ett tidsvärde? Objektet består väl också av värden av temperature, windspeed och rainfall?

Fråga 2: 
Behöver man ha ett objekt som värde för rainfall eller går det lika bra med en textsträng som i bild 1?   

Laguna Online 30239
Postad: 24 aug 2019 19:11

1) Det står "with a time value", inte att det inte får finnas andra värden i objektet. 

Laguna Online 30239
Postad: 24 aug 2019 19:14

2) "The values are either numbers or errors". 

Svara
Close