The json doesn't include end frames. The data can be taken from the start frame of the next
keyframe though.
17568
public static <T> void setEndFrames(List<? extends Keyframe<T>> keyframes) {
    int size = keyframes.size();
    for (int i = 0; i < size - 1; i++) {
      // In the json, the keyframes only contain their starting frame.
      Keyframe<T> keyframe = keyframes.get(i);
      Keyframe<T> nextKeyframe = keyframes.get(i + 1);
      keyframe.endFrame = nextKeyframe.startFrame;
      if (keyframe.endValue == null && nextKeyframe.startValue != null) {
        keyframe.endValue = nextKeyframe.startValue;
        if (keyframe instanceof PathKeyframe) {
          ((PathKeyframe) keyframe).createPath();
        }
      }
    }
    Keyframe<?> lastKeyframe = keyframes.get(size - 1);
    if ((lastKeyframe.startValue == null || lastKeyframe.endValue == null) && keyframes.size() > 1) {
      // The only purpose the last keyframe has is to provide the end frame of the previous
      // keyframe.
      //noinspection SuspiciousMethodCalls
      keyframes.remove(lastKeyframe);
    }
  }
1241320
@Override protected void execImpl() {
    Frame frame = source;
    if (shuffle) {
      // FIXME: switch to global shuffle
      frame = MRUtils.shuffleFramePerChunk(Utils.generateShuffledKey(frame._key), frame, seed);
      frame.delete_and_lock(null).unlock(null); // save frame to DKV
      // delete frame on the end
      gtrash(frame);
    }
    FrameSplitter fs = new FrameSplitter(frame, ratios);
    H2O.submitTask(fs);

    Frame[] splits = fs.getResult();

    split_keys = new Key [splits.length];
    split_rows = new long[splits.length];
    float rsum = Utils.sum(ratios);
    split_ratios = Arrays.copyOf(ratios, splits.length);
    split_ratios[splits.length-1] = 1f-rsum;
    long sum = 0;
    for(int i=0; i<splits.length; i++) {
      sum += splits[i].numRows();
      split_keys[i] = splits[i]._key;
      split_rows[i] = splits[i].numRows();
    }
    assert sum == source.numRows() : "Frame split produced wrong number of rows: nrows(source) != sum(nrows(splits))";
  }
1194581
public Frame process(Frame frame) {
    	count = frame.getLength() / 2;
        Frame res = Memory.allocate(count);
        
        byte[] data=frame.getData();
        byte[] resData=res.getData();
        
        for (i = 0,j = 0; i < count; i++,j++)
        	resData[i]=EncoderData.aLawCompressTable[data[j+1] & 0xff][data[j++] & 0xff];        	
        
        res.setOffset(0);
        res.setLength(count);
        res.setFormat(alaw);
        res.setTimestamp(frame.getTimestamp());
        res.setDuration(frame.getDuration());
        res.setEOM(frame.isEOM());
        res.setSequenceNumber(frame.getSequenceNumber());

        return res;
    }
627360
def wrap_json(cls, json):
        
        if json is None:
            return None
        channel = Channel.wrap_json(json.get('channel'))
        s = Stream(game=json.get('game'),
                   channel=channel,
                   twitchid=json.get('_id'),
                   viewers=json.get('viewers'),
                   preview=json.get('preview'))
        return s
519315
def _from_json(json_data):
        
        if len(json_data) >= 6:
            return BoundingBox(
                        Coordinate(_parse_float(json_data[0]),
                                   _parse_float(json_data[1]),
                                   _parse_float(json_data[2])),
                        Coordinate(_parse_float(json_data[3]),
                                   _parse_float(json_data[4]),
                                   _parse_float(json_data[5])))
        else:
            raise USGSException("The bounding box information was incomplete.")
1042069
private void endJSON()
    throws SAXException
    {   
        if (logger.isLoggable(Level.FINER)) logger.entering(className, "endJSON()");

        try
        {
            this.head.writeObject(this.osWriter, 0, true, this.compact);
            this.head    = null;
            this.current = null;
            this.previousObjects.clear();
        }
        catch (Exception ex)
        {
            SAXException saxEx = new SAXException(ex);
            saxEx.initCause(ex);
            throw saxEx;
        }

        if (logger.isLoggable(Level.FINER)) logger.exiting(className, "endJSON()");
    }
298431
private JSON getJSON() throws JSONMarshallException {
        if (json == null) {
            JSONSettings settings = new JSONSettings(Include.NON_NULL);
            json = JSONFactory.newInstance(settings);
        }
        return json;
    }
545248
function toWebM(frames, outputAsArray){
		var info = checkFrames(frames);

		//max duration by cluster in milliseconds
		var CLUSTER_MAX_DURATION = 30000;

		var EBML = [
			{
				"id": 0x1a45dfa3, // EBML
				"data": [
					{
						"data": 1,
						"id": 0x4286 // EBMLVersion
					},
					{
						"data": 1,
						"id": 0x42f7 // EBMLReadVersion
					},
					{
						"data": 4,
						"id": 0x42f2 // EBMLMaxIDLength
					},
					{
						"data": 8,
						"id": 0x42f3 // EBMLMaxSizeLength
					},
					{
						"data": "webm",
						"id": 0x4282 // DocType
					},
					{
						"data": 2,
						"id": 0x4287 // DocTypeVersion
					},
					{
						"data": 2,
						"id": 0x4285 // DocTypeReadVersion
					}
				]
			},
			{
				"id": 0x18538067, // Segment
				"data": [
					{
						"id": 0x1549a966, // Info
						"data": [
							{
								"data": 1e6, //do things in millisecs (num of nanosecs for duration scale)
								"id": 0x2ad7b1 // TimecodeScale
							},
							{
								"data": "whammy",
								"id": 0x4d80 // MuxingApp
							},
							{
								"data": "whammy",
								"id": 0x5741 // WritingApp
							},
							{
								"data": doubleToString(info.duration),
								"id": 0x4489 // Duration
							}
						]
					},
					{
						"id": 0x1654ae6b, // Tracks
						"data": [
							{
								"id": 0xae, // TrackEntry
								"data": [
									{
										"data": 1,
										"id": 0xd7 // TrackNumber
									},
									{
										"data": 1,
										"id": 0x73c5 // TrackUID
									},
									{
										"data": 0,
										"id": 0x9c // FlagLacing
									},
									{
										"data": "und",
										"id": 0x22b59c // Language
									},
									{
										"data": "V_VP8",
										"id": 0x86 // CodecID
									},
									{
										"data": "VP8",
										"id": 0x258688 // CodecName
									},
									{
										"data": 1,
										"id": 0x83 // TrackType
									},
									{
										"id": 0xe0,  // Video
										"data": [
											{
												"data": info.width,
												"id": 0xb0 // PixelWidth
											},
											{
												"data": info.height,
												"id": 0xba // PixelHeight
											}
										]
									}
								]
							}
						]
					},
					{
						"id": 0x1c53bb6b, // Cues
						"data": [
							//cue insertion point
						]
					}

					//cluster insertion point
				]
			}
		 ];


		var segment = EBML[1];
		var cues = segment.data[2];

		//Generate clusters (max duration)
		var frameNumber = 0;
		var clusterTimecode = 0;
		while(frameNumber < frames.length){

			var cuePoint = {
					"id": 0xbb, // CuePoint
					"data": [
						{
							"data": Math.round(clusterTimecode),
							"id": 0xb3 // CueTime
						},
						{
							"id": 0xb7, // CueTrackPositions
							"data": [
								{
									"data": 1,
									"id": 0xf7 // CueTrack
								},
								{
									"data": 0, // to be filled in when we know it
									"size": 8,
									"id": 0xf1 // CueClusterPosition
								}
							]
						}
					]
				};

			cues.data.push(cuePoint);

			var clusterFrames = [];
			var clusterDuration = 0;
			do {
				clusterFrames.push(frames[frameNumber]);
				clusterDuration += frames[frameNumber].duration;
				frameNumber++;
			}while(frameNumber < frames.length && clusterDuration < CLUSTER_MAX_DURATION);

			var clusterCounter = 0;
			var cluster = {
					"id": 0x1f43b675, // Cluster
					"data": [
						{
							"data": Math.round(clusterTimecode),
							"id": 0xe7 // Timecode
						}
					].concat(clusterFrames.map(function(webp){
						var block = makeSimpleBlock({
							discardable: 0,
							frame: webp.data.slice(4),
							invisible: 0,
							keyframe: 1,
							lacing: 0,
							trackNum: 1,
							timecode: Math.round(clusterCounter)
						});
						clusterCounter += webp.duration;
						return {
							data: block,
							id: 0xa3
						};
					}))
				}

			//Add cluster to segment
			segment.data.push(cluster);
			clusterTimecode += clusterDuration;
		}

		//First pass to compute cluster positions
		var position = 0;
		for(var i = 0; i < segment.data.length; i++){
			if (i >= 3) {
				cues.data[i-3].data[1].data[1].data = position;
			}
			var data = generateEBML([segment.data[i]], outputAsArray);
			position += data.size || data.byteLength || data.length;
			if (i != 2) { // not cues
				//Save results to avoid having to encode everything twice
				segment.data[i] = data;
			}
		}

		return generateEBML(EBML, outputAsArray)
	}
81156
def end(self):
        """"""
        for comic in self.data:
            with codecs.open(self.jsonFn(comic), 'w', self.encoding) as f:
                json.dump(self.data[comic], f, indent=2, separators=(',', ': '), sort_keys=True)
53406
private void decodeBitmapData(GifFrame frame) {
        workBufferSize = 0;
        workBufferPosition = 0;
        if (frame != null) {
            // Jump to the frame start position.
            rawData.position(frame.bufferFrameStart);
        }

        int npix = (frame == null) ? header.width * header.height : frame.iw * frame.ih;
        int available, clear, codeMask, codeSize, endOfInformation, inCode, oldCode, bits, code, count,
                i, datum,
                dataSize, first, top, bi, pi;

        if (mainPixels == null || mainPixels.length < npix) {
            // Allocate new pixel array.
            mainPixels = bitmapProvider.obtainByteArray(npix);
        }
        if (prefix == null) {
            prefix = new short[MAX_STACK_SIZE];
        }
        if (suffix == null) {
            suffix = new byte[MAX_STACK_SIZE];
        }
        if (pixelStack == null) {
            pixelStack = new byte[MAX_STACK_SIZE + 1];
        }

        // Initialize GIF data stream decoder.
        dataSize = readByte();
        clear = 1 << dataSize;
        endOfInformation = clear + 1;
        available = clear + 2;
        oldCode = NULL_CODE;
        codeSize = dataSize + 1;
        codeMask = (1 << codeSize) - 1;
        for (code = 0; code < clear; code++) {
            // XXX ArrayIndexOutOfBoundsException.
            prefix[code] = 0;
            suffix[code] = (byte) code;
        }

        // Decode GIF pixel stream.
        datum = bits = count = first = top = pi = bi = 0;
        for (i = 0; i < npix; ) {
            // Load bytes until there are enough bits for a code.
            if (count == 0) {
                // Read a new data block.
                count = readBlock();
                if (count <= 0) {
                    status = STATUS_PARTIAL_DECODE;
                    break;
                }
                bi = 0;
            }

            datum += (((int) block[bi]) & 0xff) << bits;
            bits += 8;
            bi++;
            count--;

            while (bits >= codeSize) {
                // Get the next code.
                code = datum & codeMask;
                datum >>= codeSize;
                bits -= codeSize;

                // Interpret the code.
                if (code == clear) {
                    // Reset decoder.
                    codeSize = dataSize + 1;
                    codeMask = (1 << codeSize) - 1;
                    available = clear + 2;
                    oldCode = NULL_CODE;
                    continue;
                }

                if (code > available) {
                    status = STATUS_PARTIAL_DECODE;
                    break;
                }

                if (code == endOfInformation) {
                    break;
                }

                if (oldCode == NULL_CODE) {
                    pixelStack[top++] = suffix[code];
                    oldCode = code;
                    first = code;
                    continue;
                }
                inCode = code;
                if (code >= available) {
                    pixelStack[top++] = (byte) first;
                    code = oldCode;
                }
                while (code >= clear) {
                    pixelStack[top++] = suffix[code];
                    code = prefix[code];
                }
                first = ((int) suffix[code]) & 0xff;
                pixelStack[top++] = (byte) first;

                // Add a new string to the string table.
                if (available < MAX_STACK_SIZE) {
                    prefix[available] = (short) oldCode;
                    suffix[available] = (byte) first;
                    available++;
                    if (((available & codeMask) == 0) && (available < MAX_STACK_SIZE)) {
                        codeSize++;
                        codeMask += available;
                    }
                }
                oldCode = inCode;

                while (top > 0) {
                    // Pop a pixel off the pixel stack.
                    mainPixels[pi++] = pixelStack[--top];
                    i++;
                }
            }
        }

        // Clear missing pixels.
        for (i = pi; i < npix; i++) {
            mainPixels[i] = 0;
        }
    }
211320
def _to_json(self, sort_keys=False, indent=4):
        
        return json.dumps(self, sort_keys=sort_keys, indent=indent, cls=CtabAtomBondEncoder)
776399
function(){
            
                /*
                 * keyframes:
                 *   : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' {
                 *   ;
                 */
                var tokenStream = this._tokenStream,
                    token,
                    tt,
                    name;            
                    
                tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
                this._readWhitespace();
                name = this._keyframe_name();
                
                this._readWhitespace();
                tokenStream.mustMatch(Tokens.LBRACE);
                    
                this.fire({
                    type:   "startkeyframes",
                    name:   name,
                    line:   name.line,
                    col:    name.col
                });                
                
                this._readWhitespace();
                tt = tokenStream.peek();
                
                //check for key
                while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) {
                    this._keyframe_rule();
                    this._readWhitespace();
                    tt = tokenStream.peek();
                }           
                
                this.fire({
                    type:   "endkeyframes",
                    name:   name,
                    line:   name.line,
                    col:    name.col
                });                      
                    
                this._readWhitespace();
                tokenStream.mustMatch(Tokens.RBRACE);                    
                
            }
536870
function processJson(json) {
                    // now we have an array of lines, so let's convert them to metrics

                    var interpolate = graph.horizon && graph.horizon.interpolateGaps;
                    var squash = graph.horizon && graph.horizon.squashNegative;
                    var sortMethod = graph.horizon && graph.horizon.sortMethod ? graph.horizon.sortMethod : "name";
                    
                    // do sorting before we parse

                    function reducer(individualSeries, initialFunction, reductionFunction) {
                        if (individualSeries.length == 0) {
                            return NaN;
                        }
                        var initial = initialFunction(individualSeries[0][1]);
                        var i=1;
                        for (; initial==null && i<individualSeries.length; i++) {
                            initial = initialFunction(individualSeries[i][1]);
                        }
                        for (; i<individualSeries.length; i++) {
                            if (individualSeries[i][1] != null) {
                                initial = reductionFunction(initial, individualSeries[i][1]);
                            }
                        }
                        return initial;
                    }

                    function avg(individualSeries) {
                        return reducer(individualSeries, function(a) {return a}, function(a,b) {return a+b})  // sum
                            / reducer(individualSeries, function(a) {return a==null?null:1}, function(a,_) {return a+1;}); // count
                    }

                    function preCacheSortParameters(allJson, f) {
                        for (var i=0; i<allJson.length; i++) {
                            var val = f(allJson[i].dps);
                            allJson[i]._preCachedSortParameter = val;
                        }
                    }

                    function compareStrings(a,b) {
                        for (var pos=0; ; pos++) {
                            if (a.length > pos && b.length > pos) {
                                if (a.charAt(pos) < b.charAt(pos)) {
                                    return -1;
                                }
                                if (a.charAt(pos) > b.charAt(pos)) {
                                    return 1;
                                }
                            }
                            else if (a.length > pos) {
                                return 1;
                            }
                            else if (b.length > pos) {
                                return -1;
                            }
                            else {
                                return 0;
                            }
                        }
                    }

                    // sorting of responses
                    switch (sortMethod) {
                        case "min":
                            preCacheSortParameters(json, function(series) {return reducer(series, function(a) {return a;}, Math.min)});
                            json.sort(function(a,b) {return a._preCachedSortParameter- b._preCachedSortParameter});
                            break;
                        case "max":
                            preCacheSortParameters(json, function(series) {return reducer(series, function(a) {return a;}, Math.max)});
                            json.sort(function(a,b) {return a._preCachedSortParameter- b._preCachedSortParameter});
                            break;
                        case "avg":
                            preCacheSortParameters(json, function(series) {return avg(series)});
                            json.sort(function(a,b) {return a._preCachedSortParameter- b._preCachedSortParameter});
                            break;
                        // these are sorted later
                        case "name":
                        default:
                            var sortFunction = function (a,b) {
                                return compareStrings(graphServices.timeSeriesName(a),graphServices.timeSeriesName(b));
                            };
                            // default: by name
                            json.sort(sortFunction);
                    }

                    var parsed = renderer.cubism_parser(json, start, stepSize, stop, interpolate, squash); // array response
                    
                    // construct cMetrics
                    var cMetrics = [];

                    var context = ret.context()
                        .serverDelay(diff)
                        .step(stepSize)
                        .size(width)
                        .stop();

                    var addMetric = function(cMetrics, metricData, name)
                    {
                        cMetrics.push(context.metric(function (start, stop, step, callback) {
                            callback(null, metricData);
                        }, name));
                    }


                    for (var i=0; i<parsed.length; i++) {
                        var name = graphServices.timeSeriesName(json[i]);
                        addMetric(cMetrics, parsed[i], name);
                    }
                    
                    ret.d3render(renderContext, graph, context, cMetrics, divSelector);

                    var yAxisParams = {
                        squashNegative: squash
                    };
                    ret.tsdb_export_link = graphServices.tsdbGraphUrl("/#", renderContext, config, global, graph, queries, "x1y1", downsampleOverrideFn, yAxisParams, /*y2AxisParams*/null, /*keyParams*/{}, /*lineSmoothing*/false, /*style*/null, /*globalAnnotations*/false);
                    renderContext.renderMessages[graph.id] = "";
                    renderContext.graphRendered(graph.id);
                    return;
                }
1300771
def loadJSON(self, json_string):
        
        g = get_root(self).globals
        data = json.loads(json_string)['appdata']
        # first set the parameters which change regardless of mode
        # number of exposures
        numexp = data.get('numexp', 0)
        if numexp == -1:
            numexp = 0
        self.number.set(numexp)
        # Overscan (x, y)
        if 'oscan' in data:
            self.oscan.set(data['oscan'])
        if 'oscany' in data:
            self.oscan.set(data['oscany'])
        # LED setting
        self.led.set(data.get('led_flsh', 0))
        # Dummy output enabled
        self.dummy.set(data.get('dummy_out', 0))
        # Fast clocking option?
        self.fastClk.set(data.get('fast_clks', 0))
        # readout speed
        self.readSpeed.set(data.get('readout', 'Slow'))
        # dwell
        dwell = data.get('dwell', 0)
        self.expose.set(str(float(dwell)))

        # multipliers
        mult_values = data.get('multipliers',
                               (1, 1, 1, 1, 1))
        self.nmult.setall(mult_values)

        # look for nodpattern in data
        nodPattern = data.get('nodpattern', {})
        if nodPattern and g.cpars['telins_name'] == 'GTC':
            self.nodPattern = nodPattern
            self.nod.set(True)
            self.clear.set(True)
        else:
            self.nodPattern = {}
            self.nod.set(False)

        # binning
        self.quad_frame.xbin.set(data.get('xbin', 1))
        self.quad_frame.ybin.set(data.get('ybin', 1))
        self.drift_frame.xbin.set(data.get('xbin', 1))
        self.drift_frame.ybin.set(data.get('ybin', 1))

        # now for the behaviour which depends on mode
        if 'app' in data:
            self.app.set(data['app'])
            app = data['app']

            if app == 'Drift':
                # disable clear mode in drift
                self.clear.set(0)
                # only one pair allowed
                self.wframe.npair.set(1)

                # set the window pair values
                labels = ('x1start_left', 'y1start',
                          'x1start_right', 'x1size',
                          'y1size')
                if not all(label in data for label in labels):
                    raise DriverError('Drift mode application missing window params')
                # now actually set them
                self.wframe.xsl[0].set(data['x1start_left'])
                self.wframe.xsr[0].set(data['x1start_right'])
                self.wframe.ys[0].set(data['y1start'])
                self.wframe.nx[0].set(data['x1size'])
                self.wframe.ny[0].set(data['y1size'])
                self.wframe.check()

            elif app == 'FullFrame':
                # enable clear mode if set
                self.clear.set(data.get('clear', 0))

            elif app == 'Windows':
                # enable clear mode if set
                self.clear.set(data.get('clear', 0))
                nquad = 0
                for nw in range(2):
                    labels = ('x{0}start_lowerleft y{0}start x{0}start_upperleft x{0}start_upperright ' +
                              'x{0}start_lowerright x{0}size y{0}size').format(nw+1).split()
                    if all(label in data for label in labels):
                        xsll = data[labels[0]]
                        xslr = data[labels[4]]
                        xsul = data[labels[2]]
                        xsur = data[labels[3]]
                        ys = data[labels[1]]
                        nx = data[labels[5]]
                        ny = data[labels[6]]
                        self.wframe.xsll[nw].set(xsll)
                        self.wframe.xslr[nw].set(xslr)
                        self.wframe.xsul[nw].set(xsul)
                        self.wframe.xsur[nw].set(xsur)
                        self.wframe.ys[nw].set(ys)
                        self.wframe.nx[nw].set(nx)
                        self.wframe.ny[nw].set(ny)
                        nquad += 1
                    else:
                        break
                self.wframe.nquad.set(nquad)
                self.wframe.check()
1206900
@SuppressWarnings("unused") // called through reflection by RequestServer
  public FramesV3 columnSummary(int version, FramesV3 s) {
    Frame frame = getFromDKV("key", s.frame_id.key()); // safe
    Vec vec = frame.vec(s.column);
    if (null == vec)
      throw new H2OColumnNotFoundArgumentException("column", s.frame_id.toString(), s.column);

    // Compute second pass of rollups: the histograms.
    vec.bins();

    // Cons up our result
    s.frames = new FrameV3[1];
    s.frames[0] = new FrameV3(new Frame(new String[]{s.column}, new Vec[]{vec}), s.row_offset, s.row_count, s.column_offset, s.column_count);
    return s;
  }
940831
def to_json(self, data):
        
        # Don't forget the empty line at the end of the file
        return (
            json.dumps(
                data,
                sort_keys=True,
                indent=4,
                separators=(",", ": "),
                default=self.json_converter,
            )
            + "\n"
        )
162989
def formatetfindexjson(fundbjson):
        """"""
        result = {}
        for row in fundbjson["rows"]:
            cell = row["cell"]
            fundb_id = cell["fund_id"]
            result[fundb_id] = cell
        return result