All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cds.adapter.odata.v4.serializer.json.Apply2Json Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
/**************************************************************************
 * (C) 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. *
 **************************************************************************/
package com.sap.cds.adapter.odata.v4.serializer.json;

import java.io.IOException;
import java.util.Map;

import org.apache.olingo.commons.api.Constants;

import com.fasterxml.jackson.core.JsonGenerator;
import com.sap.cds.adapter.odata.v4.serializer.json.api.Data2Json;
import com.sap.cds.adapter.odata.v4.serializer.json.primitive.Number2Json;
import com.sap.cds.adapter.odata.v4.serializer.json.primitive.String2Json;
import com.sap.cds.impl.parser.token.Jsonizer;

public class Apply2Json implements Data2Json>> {

	String2Json context;
	String2Json metadataEtag;
	Number2Json>> count;
	String2Json nextLink;

	Apply2Json() {
	}

	@Override
	public void toJson(Iterable> rows, JsonGenerator json) throws IOException {
		json.writeStartObject();
		if (context != null) {
			context.toJson(null, json);
		}
		if (metadataEtag != null) {
			metadataEtag.toJson(null, json);
		}		
		if (count != null) {
			count.toJson(rows, json);
		}
		if (nextLink != null) {
			nextLink.toJson(null, json);
		}

		json.writeFieldName(Constants.VALUE);
		json.writeRawValue(Jsonizer.json(rows));

		json.writeEndObject();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy