Converting CSV file to LIBSVM compatible data file using python - java

I am doing a project using libsvm and I am preparing my data to use the lib. How can I convert CSV file to LIBSVM compatible data?
CSV File:
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/datasets/data/iris.csv
In the frequencies questions:
How to convert other data formats to LIBSVM format?
It depends on your data format. A simple way is to use libsvmwrite in the libsvm matlab/octave interface. Take a CSV (comma-separated values) file in UCI machine learning repository as an example. We download SPECTF.train. Labels are in the first column. The following steps produce a file in the libsvm format.
matlab> SPECTF = csvread('SPECTF.train'); % read a csv file
matlab> labels = SPECTF(:, 1); % labels from the 1st column
matlab> features = SPECTF(:, 2:end);
matlab> features_sparse = sparse(features); % features must be in a sparse matrix
matlab> libsvmwrite('SPECTFlibsvm.train', labels, features_sparse);
The tranformed data are stored in SPECTFlibsvm.train.
Alternatively, you can use convert.c to convert CSV format to libsvm format.
but I don't wanna use matlab, I use python.
I found this solution as well using JAVA
Can anyone recommend a way to tackle this problem ?

You can use csv2libsvm.py to convert csv to libsvm data
python csv2libsvm.py iris.csv libsvm.data 4 True
where 4 means target index, and True means csv has a header.
Finally, you can get libsvm.data as
0 1:5.1 2:3.5 3:1.4 4:0.2
0 1:4.9 2:3.0 3:1.4 4:0.2
0 1:4.7 2:3.2 3:1.3 4:0.2
0 1:4.6 2:3.1 3:1.5 4:0.2
...
from iris.csv
150,4,setosa,versicolor,virginica
5.1,3.5,1.4,0.2,0
4.9,3.0,1.4,0.2,0
4.7,3.2,1.3,0.2,0
4.6,3.1,1.5,0.2,0
...

csv2libsvm.py does not work with Python3, and also it does not support label targets (string targets), I have slightly modified it. Now It should work with Python3 as well as wıth the label targets.
I am very new to Python, so my code may do not follow the best practices, but I hope it is good enough to help someone.
#!/usr/bin/env python
"""
Convert CSV file to libsvm format. Works only with numeric variables.
Put -1 as label index (argv[3]) if there are no labels in your file.
Expecting no headers. If present, headers can be skipped with argv[4] == 1.
"""
import sys
import csv
import operator
from collections import defaultdict
def construct_line(label, line, labels_dict):
new_line = []
if label.isnumeric():
if float(label) == 0.0:
label = "0"
else:
if label in labels_dict:
new_line.append(labels_dict.get(label))
else:
label_id = str(len(labels_dict))
labels_dict[label] = label_id
new_line.append(label_id)
for i, item in enumerate(line):
if item == '' or float(item) == 0.0:
continue
elif item=='NaN':
item="0.0"
new_item = "%s:%s" % (i + 1, item)
new_line.append(new_item)
new_line = " ".join(new_line)
new_line += "\n"
return new_line
# ---
input_file = sys.argv[1]
try:
output_file = sys.argv[2]
except IndexError:
output_file = input_file+".out"
try:
label_index = int( sys.argv[3] )
except IndexError:
label_index = 0
try:
skip_headers = sys.argv[4]
except IndexError:
skip_headers = 0
i = open(input_file, 'rt')
o = open(output_file, 'wb')
reader = csv.reader(i)
if skip_headers:
headers = reader.__next__()
labels_dict = {}
for line in reader:
if label_index == -1:
label = '1'
else:
label = line.pop(label_index)
new_line = construct_line(label, line, labels_dict)
o.write(new_line.encode('utf-8'))

Related

My java Base64 results are not the same as php

I have previously posted a question related to this work link but I am posting a new one because the question is not completely resolved
I am working on converting the completed code into java with php.
It is a function that reads encrypted files, decrypts them by 16 bytes, makes them into a single string, and encodes them with base 64.
php is already on the server and running, and I have to use java to produce the same result.
If you decrypt the read file,
<?xml version="1.0" encoding="utf-8" ?>
<FileInfo>
...
<TextData> (text data) </TextData>
</FileInfo>
(image data)
It is in the format, and the text data in shows php and java exactly the same.
I am trying to encode the image data part into base64, but the result is different from php.
This is the part of the php code I have that decrypts and processes the read file
$fileContentArray = array(16);
$transContentArray = array(16);
$fileRead = fread($fp,16);
for($i = 0 ; $i < strlen($fileRead); $i++){
$fileContentArray[$i] = ord($fileRead[$i]);
}
$seed->SeedDecrypt($fileContentArray,$pdwRoundKey,$transContentArray);
$transStr = call_user_func_array("pack",array_merge(array("C16"),$transContentArray));
$mergeStr .= $transStr;
}
$dataExplode = explode("<TextData>",trim($mergeStr) );
$dataExplode1 = explode("</FileInfo>",trim($dataExplode[1]) );
$dataExplode2 = explode("</TextData>",$dataExplode1[0]);
$textData = iconv("EUC-KR","utf-8",$dataExplode2[0]);
$imageData = base64_encode(trim($dataExplode1[1]));
And this is the same part of the java code I wrote
byte[] fileContentArray=new byte[n];
for(int i=0;i<fileContentArray.length;i++){
fileContentArray[i]=mergeArr[nReadCur+i];
}
seed.SeedDecrypt(fileContentArray, pdwRoundKey, outbuf);
System.arraycopy(outbuf, 0, resultArr, nReadCur, outbuf.length);
nReadCur=nReadCur+fileContentArray.length;
p=p+fileContentArray.length;
if(p>=nFileSize){
fis.close();
break;
}
}//while
mergeStr=new String(resultArr,"MS949");
String[] dataExplode=mergeStr.trim().split("<TextData>");
String[] dataExplode1=dataExplode[1].trim().split("</FileInfo>");
String[] dataExplode2=dataExplode1[0].trim().split("</TextData>");
String textData = "";
String imageData = "";
textData=dataExplode2[0];
imageData=dataExplode1[1];
Encoder encoder=Base64.getEncoder();
Decoder decoder=Base64.getDecoder();
byte[] encArr=encoder.encode(imageData.trim().getBytes("MS949"));
imageData=new String(encArr,"MS949");
As a result of encoding image data into base64
php: R0lGODlhAwNLBPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/ ... VzpYirO0le55zF0=
java: R0lGODlhAwNLBD8AAAAAAAAAMwAAZgAAPwAAPwAAPwArAAArMwArZgArPwArPwArPwBVAABVMwBVZgBVPwBVPwBVPwA/AAA/MwA/ZgA/PwA/PwA/PwA/ ... DAQEAOz9GPz8/IXY=
As you can see, the result values are output differently.
Is there anything I'm missing? What should I do to make the result of java the same as php?
Also, MergeStr, who has read the file,
java:
GIF89aK? 3 f ? ? ? + +3 +f +? +? +? U U3 Uf U? U? U? ? ?3 ?f ?? ?? ?? ? ?3 챖 첌 ぬ ? ? ?3 ?f ??
...
J뇽杞H?*]苛⒢쬝쥻쒳뎁諾X...
A?h?~?0a?2$ #삁?d?Dd??e ...
...
WC ;홃?뿿!v
php:
GIF89aK? 3 f ? ?  + +3 +f +? +? + U U3 Uf U? U? U 3 f ? ?  ? ? 챖 첌 ぬ ? ? ? ? ? 螂 ?  3 f ? ? ...
A??~?a?$ #삁?d?Dd?e...
...
WC ;홃??v余퍙W:X뒽킉??
Like this, there is a new line text that I didn't put in, and there's a slight difference in result. Is this a simple difference in encoding? And does this affect the base64 conversion?
I tried encoding with UTF-8 and failed again,
and I used this code to load all bytes of the file at once
FileInputStream fis = new FileInputStream(tpf);
fis.read(mergeArr);
Java uses a little bit different encoding for base64 than PHP. You may use these helper functions to make them compatible to the Java version.
function base64url_encode($data)
{
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
function base64url_decode($data, $strict = false)
{
return base64_decode(strtr($data, '-_', '+/'), $strict);
}

Pivoting DataFrame - Spark SQL

I have a DataFrame containing below:
TradeId|Source
ABC|"USD,333.123,20170605|USD,-789.444,20170605|GBP,1234.567,20150602"
I want to pivot this data so it turns into below
TradeId|CCY|PV
ABC|USD|333.123
ABC|USD|-789.444
ABC|GBP|1234.567
The number of CCY|PV|Date triplets in the column "Source" is not fixed. I could do it in ArrayList but that requires to load the data in JVM and defeats the whole point of Spark.
Lets say my DataFrame looks as below:
DataFrame tradesSnap = this.loadTradesSnap(reportRequest);
String tempTable = getTempTableName();
tradesSnap.registerTempTable(tempTable);
tradesSnap = tradesSnap.sqlContext().sql("SELECT TradeId, Source FROM " + tempTable);
If you read databricks pivot, it says " A pivot is an aggregation where one (or more in the general case) of the grouping columns has its distinct values transposed into individual columns." And this is not what you desire I guess
I would suggest you to use withColumn and functions to get the final output you desire. You can do as following considering dataframe is what you have
+-------+----------------------------------------------------------------+
|TradeId|Source |
+-------+----------------------------------------------------------------+
|ABC |USD,333.123,20170605|USD,-789.444,20170605|GBP,1234.567,20150602|
+-------+----------------------------------------------------------------+
You can do the following using explode, split and withColumn to get the desired output
val explodedDF = dataframe.withColumn("Source", explode(split(col("Source"), "\\|")))
val finalDF = explodedDF.withColumn("CCY", split($"Source", ",")(0))
.withColumn("PV", split($"Source", ",")(1))
.withColumn("Date", split($"Source", ",")(2))
.drop("Source")
finalDF.show(false)
The final output is
+-------+---+--------+--------+
|TradeId|CCY|PV |Date |
+-------+---+--------+--------+
|ABC |USD|333.123 |20170605|
|ABC |USD|-789.444|20170605|
|ABC |GBP|1234.567|20150602|
+-------+---+--------+--------+
I hope this solves your issue
Rather than pivoting, what you are trying to achieve looks more like flatMap.
To put it simply, by using flatMap on a Dataset you apply to each row a function (map) that itself would produce a sequence of rows. Each set of rows is then concatenated into a single sequence (flat).
The following program shows the idea:
import org.apache.spark.sql.SparkSession
case class Input(TradeId: String, Source: String)
case class Output(TradeId: String, CCY: String, PV: String, Date: String)
object FlatMapExample {
// This function will produce more rows of output for each line of input
def splitSource(in: Input): Seq[Output] =
in.Source.split("\\|", -1).map {
source =>
println(source)
val Array(ccy, pv, date) = source.split(",", -1)
Output(in.TradeId, ccy, pv, date)
}
def main(args: Array[String]): Unit = {
// Initialization and loading
val spark = SparkSession.builder().master("local").appName("pivoting-example").getOrCreate()
import spark.implicits._
val input = spark.read.options(Map("sep" -> "|", "header" -> "true")).csv(args(0)).as[Input]
// For each line in the input, split the source and then
// concatenate each "sub-sequence" in a single `Dataset`
input.flatMap(splitSource).show
}
}
Given your input, this would be the output:
+-------+---+--------+--------+
|TradeId|CCY| PV| Date|
+-------+---+--------+--------+
| ABC|USD| 333.123|20170605|
| ABC|USD|-789.444|20170605|
| ABC|GBP|1234.567|20150602|
+-------+---+--------+--------+
You can now take the result and save it to a CSV, if you want.

Using RapidMiner Textprocessing plugin in Java - Not able to use 'Document' object in the code

I am using RapidMiner 5. I want to make a text preprocessing module to use with a categorization system. I created a process in RapidMiner with these steps.
Tokenize
Transform Case
Stemming
Filtering stopwords
Generating n-grams
I want to write a script to do spell correction for these words. So, I used 'Execute Script' operator and wrote a groovy script for doing this (from here- raelcunha). This is the code ( helped by RapidMiner community) I wrote in execute Script operator of rapid miner.
Document doc=input[0]
List<Token> newTokens = new LinkedList<Token>();
nWords=train("set2.txt")
for (Token token : doc.getTokenSequence()) {
//String output=correct((String)token.getToken(),nWords)
println token.getToken();
Token nToken = new Token(correct("garbge",nWords), token);
newTokens.add(nToken);
}
doc.setTokenSequence(newTokens);
return doc;
This is the code for spell correction. ( Thanks to Norvig.)
import com.rapidminer.operator.text.Document;
import com.rapidminer.operator.text.Token;
import java.util.List;
import java.util.LinkedList;
def train(f){
def n = [:]
new File(f).eachLine{it.toLowerCase().eachMatch(/\w+/){n[it]=n[it]?n[it]+1:1}}
n
}
def edits(word) {
def result = [], n = word.length()-1
for(i in 0..n) result.add(word[0..<i] + word.substring(i+1))
for(i in 0..n-1) result.add(word[0..<i] + word[i+1] + word[i, i+1] + word.substring(i+2))
for(i in 0..n) for(c in 'a'..'z') result.add(word[0..<i] + c + word.substring(i+1))
for(i in 0..n) for(c in 'a'..'z') result.add(word[0..<i] + c + word.substring(i))
result
}
def correct(word, nWords) {
if(nWords[word]) return word
def list = edits(word), candidates = [:]
for(s in list) if(nWords[s]) candidates[nWords[s]] = s
if(candidates.size() > 0) return candidates[candidates.keySet().max()]
for(s in list) for(w in edits(s)) if(nWords[w]) candidates[nWords[w]] = w
return candidates.size() > 0 ? candidates[candidates.keySet().max()] : word
}
I am getting String index out of bounds exception while calling edits method.
And, I do not know how to debug this because rapidminer just tells me that there is an issue in the Execute Script operator and not saying which line of script caused this issue.
So, I am planning to do the same thing by creating an operator in Java as mentioned here-How to extend RapidMiner
The things I did:
Included all jar files from RapidMiner Lib folder , (C:\Program Files (x86)\Rapid-I\RapidMiner5\lib ) into the build path of my java project.
Started coding using the same guide the link to which is given above.
Input for my operator is a Document ( com.rapidminer.operator.text.Document)
as in the script.
But, I am not able to use this Document object in this code. Can you tell me why? Where are the text processing jars located?
For using the plugin jars, should we add some other locations to the BuildPath?

How to write data into a .SYLK File Or Convert SLK File data

I have a code that contains a function taking columns and rows and exporting it to an SLK file. It uses a specific style-sheet ( for example dates are shown in a certain way, and prices in another one). However, the file's representation has been written using a long string and is undocumented. I need to write the same function using java and wanted to know if there is a better way for re-writing this code , for instance using apache HSSFWorkbook class.
However , i don't know what my current string representation means.
So my questions are:
Is there other open source classes that i can use writing this code
Is there any site that can show me what each of this string represents ( which style ), so i can initilize the write one using HSSFWorkbook class
Thanks Ido
my current function starts like this and doesn't look good ( it's in javascript and I need to re-write it in java):
function exportToSlk(columns, rows,filename, $a) {
var formatMaps = {
"$#,###.##":"F;P34;F$2G;",
"$#0.00":"F;P34;F$2G;",
"$#0.000" : "F;P34;F$2G;",
"#,###":"F;P39;FI0G;",
"%#0.00":"F;P14;F%2G;",
"date": "F;P19;FG0G;"
};
var header = 'ID;PWXL;N;E\nO;L\nP;PGeneral\nP;P0\nP;P0.00\nP;P#,##0\nP;P#,##0.00\nP;P#,##0_);;\\(#,##0\\)\nP;P#,##0_);;[Red]\\(#,##0\\)\nP;P#,##0.00_);;\\(#,##0.00\\)\nP;P#,##0.00_);;[Red]\\(#,##0.00\\)\nP;P"$"#,##0_);;\\("$"#,##0\\)\nP;P"$"#,##0_);;[Red]\\("$"#,##0\\)\nP;P"$"#,##0.00_);;\\("$"#,##0.00\\)\nP;P"$"#,##0.00_);;[Red]\\("$"#,##0.00\\)\nP;P0%\nP;P0.00%\nP;P0.00E+00\nP;P##0.0E+0\nP;P#\\ ?/?\nP;P#\\ ??/??\nP;Pm/d/yyyy\nP;Pd\\-mmm\\-yy\nP;Pd\\-mmm\nP;Pmmm\\-yy\nP;Ph:mm\\ AM/PM\nP;Ph:mm:ss\\ AM/PM\nP;Ph:mm\nP;Ph:mm:ss\nP;Pm/d/yyyy\\ h:mm\nP;Pmm:ss\nP;Pmm:ss.0\nP;P#\nP;P[h]:mm:ss\nP;P_("$"* #,##0_);;_("$"* \\(#,##0\\);;_("$"* "-"_);;_(#_)\nP;P_(* #,##0_);;_(* \\(#,##0\\);;_(* "-"_);;_(#_)\nP;P_("$"* #,##0.00_);;_("$"* \\(#,##0.00\\);;_("$"* "-"??_);;_(#_)\nP;P_(* #,##0.00_);;_(* \\(#,##0.00\\);;_(* "-"??_);;_(#_)\nP;P_(* #,##0.000_);;_(* \\(#,##0.000\\);;_(* "-"??_);;_(#_)\nP;P_(* #,##0.0000_);;_(* \\(#,##0.0000\\);;_(* "-"??_);;_(#_)\nP;P_(* #,##0.0_);;_(* \\(#,##0.0\\);;_(* "-"??_);;_(#_)\nP;P_(* #,##0_);;_(* \\(#,##0\\);;_(* "-"??_);;_(#_)\nP;Pmmm\\-yyyy\nP;FCalibri;M220;L9\nP;FCalibri;M220;L9\nP;FCalibri;M220;L9\nP;FCalibri;M220;L9\nP;ECalibri;M220;L9\nP;ECambria;M360;SB;L57\nP;ECalibri;M300;SB;L57\nP;ECalibri;M260;SB;L57\nP;ECalibri;M220;SB;L57\nP;ECalibri;M220;L18\nP;ECalibri;M220;L21\nP;ECalibri;M220;L61\nP;ECalibri;M220;L63\nP;ECalibri;M220;SB;L64\nP;ECalibri;M220;SB;L53\nP;ECalibri;M220;L53\nP;ECalibri;M220;SB;L10\nP;ECalibri;M220;L11\nP;ECalibri;M220;SI;L24\nP;ECalibri;M220;SB;L9\nP;ECalibri;M220;L10\nP;ECalibri;M220;L9\nP;ECambria;M360;SB;L57\nP;ECalibri;M300;SB;L57\nP;ECalibri;M260;SB;L57\nP;ECalibri;M220;SB;L57\nP;ECalibri;M220;L18\nP;ECalibri;M220;L21\nP;ECalibri;M220;L61\nP;ECalibri;M220;L63\nP;ECalibri;M220;SB;L64\nP;ECalibri;M220;SB;L53\nP;ECalibri;M220;L53\nP;ECalibri;M220;SB;L10\nP;ECalibri;M220;L11\nP;ECalibri;M220;SI;L24\nP;ECalibri;M220;SB;L9\nP;ECalibri;M220;L10\nF;P0;DG0G8;M300\n';
var exported = header;
//now handle col width
for(var i=1; i<=columns.length; i++) {
exported += "F;W"+i+" "+i+" 15\n";
}
...
}

JSON - is there any XML CDATA equivalent?

I'm looking for a way that json parsing will take information as is (as if it was CDATA) - and not to try to serialize that.
We use both .net and java (client and server) - so the answer should be about JSON structure
Is there any way to achieve this structure?
Thanks.
There is no XML CDATA equivalent in JSON. But you can encode your message in a string literal using something like base64. See this question for more details.
This is a development of Raman's suggestion above.
I love the JSON format, but there are two things I want to be able to do with it and cannot:
Paste some arbitrary text into a value using a text editor
Transparently convert between XML and JSON if the XML contains CDATA sections.
This thread is germane to both these issues.
I am proposing to overcome this in the following manner, which doesn't break the formal definition of JSON, and I wonder if I'm storing up any problems if I do this?
Define a JSON-compatible string format as follows:
"<![CDATA[ (some text, escaped according to JSON rules) ]]>"
Write an Unescape routine in my favorite programming language, which unescapes anything between <![CDATA[ and ]]>. This will be called before offering any JSON file to my text editor.
Write the complementary routine to call after editing the file, which re-escapes anything between <![CDATA[ and ]]> according to JSON rules.
Then in order to paste any arbitrary data into the file, all I need to do is signal the start and end of the arbitrary data within a JSON string by typing <![CDATA[ before and ]]> after it.
This is a routine to call before and after text-editing, in Python3:
lang-python3
escape_list = {
8 : 'b',
9 : 't',
10: 'n',
12: 'f',
13: 'r',
34: '"',
} #List of ASCII character codes to escape, with their escaped equivalents
escape_char = "\\" #this must be dealt with separately
unlikely_string = "ZzFfGgQqWw"
shebang = "#!/json/unesc\n"
start_cdata = "<![CDATA["
end_cdata = "]]>"
def escapejson(json_path):
if (os.path.isfile(json_path)): #If it doesn't exist, we can't update it
with open(json_path) as json_in:
data_in = json_in.read() #use read() 'cos we're goint to treat as txt
#Set direction of escaping
if (data_in[:len(shebang)] == shebang): #data is unescaped, so re-escape
data_in = data_in[len(shebang):]
unescape = False
data_out = ""
else:
data_out = shebang
unescape = True
while (data_in != ""): #while there is still some input to deal with
x = data_in.find(start_cdata)
x1 = data_in.find(end_cdata)
if (x > -1): #something needs escaping
if (x1 <0):
print ("Unterminated CDATA section!")
exit()
elif (x1 < x): #end before next start
print ("Extra CDATA terminator!")
exit()
data_out += data_in[:x]
data_in = data_in[x:]
y = data_in.find(end_cdata) + len(end_cdata)
to_fix = data_in[:y] #this is what we're going to (un)escape
if (to_fix[len(start_cdata):].find(start_cdata) >= 0):
print ("Nested CDATA sections not supported!")
exit()
data_in = data_in[y:] #chop data to fix from front of source
if (unescape):
to_fix = to_fix.replace(escape_char + escape_char,unlikely_string)
for each_ascii in escape_list:
to_fix = to_fix.replace(escape_char + escape_list[each_ascii],chr(each_ascii))
to_fix = to_fix.replace(unlikely_string,escape_char)
else:
to_fix = to_fix.replace(escape_char,escape_char + escape_char)
for each_ascii in escape_list:
to_fix = to_fix.replace(chr(each_ascii),escape_char + escape_list[each_ascii],)
data_out += to_fix
else:
if (x1 > 0):
print ("Termination without start!")
exit()
data_out += data_in
data_in = ""
#Save all to file of same name in same location
try:
with open(json_path, 'w') as outfile:
outfile.write(data_out)
except IOError as e:
print("Writing "+ json_path + " failed "+ str(e))
else:
print("JSON file not found")
Operating on the following legal JSON data
{
"test": "<![CDATA[\n We can put all sorts of wicked things like\n \\slashes and\n \ttabs and \n \"double-quotes\"in here!]]>"
}
...will produce the following:
#!/json/unesc
{
"test": "<![CDATA[
We can put all sorts of wicked things like
\slashes and
tabs and
"double-quotes"in here!]]>"
}
In this form, you can paste in any text between the markers. Calling the rountine again will change it back to the original legal JSON.
I think this can also be made to work when converting to/from XML with CDATA regions. (I'm going to try that next!)
You can create a YAML file and convert to JSON. For example:
test.yaml
storage:
files:
- filesystem: root
path: /etc/sysconfig/network/ifcfg-eth0
mode: 644
overwrite: true
contents:
source: |
data:,
IPV6INIT=yes
IPV6_AUTOCONF=yes
... then run yaml2json_pretty (shown later), like this:
#!/bin/bash
cat test.yaml | yaml2json_pretty > test.json
... which produces:
test.json
{
"storage": {
"files": [
{
"filesystem": "root",
"path": "/etc/sysconfig/network/ifcfg-eth0",
"mode": 644,
"overwrite": true,
"contents": {
"source": "data:,\nIPV6INIT=yes\nIPV6_AUTOCONF=yes\n"
}
}
]
}
}
This is the source code of yaml2json_pretty:
#!/usr/bin/env python3
import sys, yaml, json
print(json.dumps(yaml.load(sys.stdin.read(),Loader=yaml.FullLoader), sort_keys=False, indent=2))
More tricks similar to this yaml2json_pretty at: http://github.com/frgomes/bash-scripts
http://www.json.org/ describes JSON format in details. According to it JSON doesn't support "something like CDATA" value type.
To achieve CDATA structure you can apply custom logic to handle string based values (and do it in the same way both for .net and java implementations). E.g.
{
"type" : "CDATA",
"value" : "Value that I will handle with my custom logic on java and .net side"
}

Categories

Resources