mgholam / fastjson Goto Github PK
View Code? Open in Web Editor NEWSmallest, fastest polymorphic JSON serializer
Home Page: https://www.codeproject.com/Articles/159450/fastJSON-Smallest-Fastest-Polymorphic-JSON-Seriali
License: MIT License
Smallest, fastest polymorphic JSON serializer
Home Page: https://www.codeproject.com/Articles/159450/fastJSON-Smallest-Fastest-Polymorphic-JSON-Seriali
License: MIT License
dear all, first of all, thank you so much for the project.... I'm moving from NewtonSoft JSON library but I do have a problem converting a JSON received output into my personal code...
I'm using here FastJSON 1.2.28 version, but if fails with 1.2.27 as well
the problem consists in a value being
{"id":9990552,"name":"xxxxx",....
where 9990552 is declared in my code as integer (32bit) but FastSJON fails managing it, raisng the
"Unable to cast object of type 'System.Int64' to type 'System.String'."
exception...
I found the failing code in the
internal object ParseDictionary(Dictionary<string, object> d, Dictionary<string, object> globaltypes, Type type, object input)
in the
case myPropInfoType.String: oset = (string)v; break;
line code
so I personally made a temporary work around as
//case myPropInfoType.String: oset = (string)v; break;
// andrea
case myPropInfoType.String:
oset = Convert.ToString(v);
break;
// /andrea
but I'm missing the reason why the exception is thrown... and, the underliying object model declares the value as Visual Basic integer (meaning an Int32) and the 9990552 value naturally stays in the Int32 signed integer boundaries without overflowing...
NewtonSoft JSON library manages this without excpetions..
I'm attaching the web received JSON and the VB implementation of the code using it, for your consideration and help.
TIA
Andrea
When deserializing Json data to object, the library always looks up properties with names in all lower case. This results in failure in setting property values if the corresponding DataMemberAttribute name is case sensitive.
The following example illustrates the problem (v2.1.26):
public class TestData
{
[DataMember(Name = "foo")]
public string Foo { get; set; }
[DataMember(Name = "Bar")]
public string Bar { get; set; }
}
public void ConvertTest
{
var data = new TestData
{
Foo = "foo_value",
Bar = "bar_value"
};
var jsonData = JSON.ToJSON(data);
var data2 = JSON.ToObject<TestData>(jsonData);
// OK, since data member name is "foo" which is all in lower case
Debug.Assert(data.Foo == data2.Foo);
// Fails, since data member name is "Bar", but the library looks for "bar" when setting the value
Debug.Assert(data.Bar == data2.Bar);
}
I think the problem was introduced when JSONParameters.IgnoreCaseOnDeserialize was deprecated since v2.1.7. Please see line 722 in JSON.cs (v2.1.26).
If a date contains a 2 digit or 1 digit number of milliseconds an exception is thrown by CreateInteger, called by CreateDate, it can be fixed by checking for 'Z' first then calculating the length of milliseconds:
hour = CreateInteger(value, 11, 2);
min = CreateInteger(value, 14, 2);
sec = CreateInteger(value, 17, 2);
if (value[value.Length - 1] == 'Z')
utc = true;
if (value.Length > 21 && value[19] == '.')
ms = CreateInteger(value, 20, (value.Length - (utc ? 21:20)));
Data Example:
Hey guys,
I've been stuck with this issue for a couple of days and found a work around to my problem...
Attempting to deserialize a generic class where T is a dictionary<string, List> was trying to map the List as List
Changing lines 835 and 836 of JSON.cs (inside the CreateStringKeyDictionary method) to the code below fixed the issue but probably not the most elegant of fixes and probably not the most ideal place to put the change.
else if (values.Value is IList) { var t = t2.GetGenericArguments()[0]; val = CreateGenericList((List<object>)values.Value, t2, t, globalTypes); }
The problem was that the collection is created from t2 but t1 is typeof(System.String), when it needed to be the generic arg of t2 (the IList)
basicly all need to do is modify add !UNITY_5_3_OR_NEWER to #if !SilverLight
i checked it runs in editor
We have a Json Structure that looks like this:
{ //outer type is a derived instance of AbstractWebRequest with Property "Name"
Name = "GetBlaBlaRequest",
Taskrequest = { //is a Instance of "GetBlaBlaRequest"
}
}
I can deserialize this Json.Net using a JsonRequestConverter! Is something like this also possible in your Fastjson implementation?
In Json.Net my Converter looks like this:
public override object ReadJson(
JsonReader reader,
Type objectType,
object existingValue,
JsonSerializer serializer)
{
// Load JObject from stream
JObject jObject = JObject.Load(reader);
// Create target object based on JObject
T target = Create(objectType, jObject);
// Populate the object properties
serializer.Populate(jObject.CreateReader(), target);
return target;
}
and my create code:
protected override AbstractWebRequest Create(Type objectType, JObject jObject)
{
const string requestTypeField = "Name";
if (!jObject.FieldExists(requestTypeField))
{
return null;
}
var requestName = jObject[requestTypeField].Value<string>();
var request = _container.ResolveNamed<IRequest>(requestName);
AbstractWebRequest result = null;
if (request is IInitialRequest)
{
result = new InitialWebRequest
{
TaskRequest = (IInitialRequest)request
};
}
if (request is ISubscriptionRequest)
{
result = new SubscriptionWebRequest
{
TaskRequest = (ISubscriptionRequest)request
};
}
return result;
}
Sample Code of the issue:
Partial Sample public class Media
.....
[DataMember(Name = "type_id")]
public EnumMediaType MediaType = EnumMediaType.UNDEFINED;
[DataMember(Name = "files")]
public List MediaFiles = new List();
.....
Partial Sample class MediaFile
.....
[DataMember(Name = "descriptionPT-PT")]
internal String DescriptionPTPT { get; set; }
[DataMember(Name = "descriptionEN-GB")]
internal String DescriptionENGB { get; set; }
[DataMember(Name = "descriptionES-ES")]
internal String DescriptionESES { get; set; }
[DataMember(Name = "descriptionES-CA")]
internal String DescriptionESCA { get; set; }
[DataMember(Name = "origin")]
internal String Source { get; set; }
[DataMember(Name = "video")]
internal String VideoURL { get; set; }
[DataMember(Name = "thumbnail")]
internal String VideoThumbnailURL { get; set; }
[DataMember(Name = "thumbnailextension")]
internal String VideoThumbnailExtension { get; set; }
internal String DescriptionToIncludeOnImagePath { get; set; }
[DataMember(Name = "id")]
public String ID { get; set; }
[DataMember(Name = "ext")]
public String Extension { get; set; }
.....
string mediaJSON = "[
{
"type_id": "1",
"files": [
{
"descriptionPT-PT": "46516_Papel-de-Parede-Casa-Branca-Washington-DC-Estados-Unidos-da-America_1600x1",
"descriptionEN-GB": "",
"descriptionES-CA": "",
"descriptionES-ES": "",
"id": "f8f00500-0000-0500-0000-00000020e79f",
"url": "/f8f00500-0000-0500-0000-00000020e79f.jpg",
"ext": "jpg"
}]
}
]":
List media = fastJSON.JSON.ToObject<List>(mediaJSON);
this code fail to convert ToObject
is expecting a "MediaFiles" propertie but in json gets a "files"
the json string is a 3rd party string and i cant change my class properties
can u take a look ?
tks
Is this in the works? or thought about?
Hi, with current master branch I'm unable to deserialize json string which contains list/array of some values into Dictionary<string, object>
using ToObject
method. For example this works:
var json = @"{""foo"":""some string value"",""bar"":123,""obj"":{""foo"":""some string value"",""bar"":123}}";
var dict1 = JSON.ToObject<Dictionary<string, object>>(json);
but this:
var json = @"{""list"":[1,2,3],""foo"":""some string value"",""bar"":123,""obj"":{""foo"":""some string value"",""bar"":123}}";
var dict1 = JSON.ToObject<Dictionary<string, object>>(json);
fails with System.InvalidCastException: Unable to cast object of type 'System.Object' to type 'System.Collections.IList'. Parse
method still works for both scenarios.
How can I get datetime as such format "2016-12-01 11:30:20.524"
java.lang.NullPointerException
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.createInstance(JavaBeanDeserializer.java:111)
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:565)
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:188)
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:184)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:642)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:350)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:254)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:467)
这种情况发生在当要反序列化的对象为内部类时
Hi,
we have the same problem as stated here for the Java version
alibaba/fastjson#118
so the rest is just copied:
According the JSON specification, "\0"
is not a valid JSON string and must be encoded with four hexadecimal bytes. It's not just a theoretical problem - some python JSON parsers do not accept it.
I recommend the following unit test:
public class FastJsonTest {
@Test
public void testEncodeNulByte() throws Exception {
String json = JSON.toJSONString("\0");
assertEquals("\"\\u0000\"", json);
}
}
Hi,
when adding this poject to dotnetcore via nuget I get the error
Errors in
Package fastJSON 2.1.23 is not compatible with netstandard1.6 (.NETStandard,Version=v1.6). Package fastJSON 2.1.23 supports:
- net20 (.NETFramework,Version=v2.0)
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
One or more packages are incompatible with .NETStandard,Version=v1.6
A snippit from my dependencies:
"dependencies": {
"fastJSON": "2.1.23",
"NETStandard.Library": "1.6.0"
},
版本:1.2.42
方法: JSON.toJSONString(obj);
fastjson序列化结果:
{"msg":"成功","routings":[{"adultPrice":4220,"adultTax":512,"adultTaxType":0,"applyType":0,"childPrice":3170,"childTax":392,"childTaxType":0,"currency":"RMB","data":"e042dcaa-aa26-4b64-88e9-36228d335394","fromSegments":[{"aircraftCode":"388","arrAirport":"SYD","arrTime":"2017-12-21T09: 45: 00.000+11: 00","cabin":"L","cabinClass":1,"carrier":"QF","codeShare":false,"depAirport":"HKG","depTime":"2017-12-20T21: 15: 00.000+08: 00","flightNumber":"118","stopCities":""}],"nationalityType":0,"priceType":0,"retSegments":[],"rule":{"baggage":"-","endorse":"-","endorsement":1,"hasBaggage":1,"hasEndorse":1,"hasNoShow":1,"hasRefund":1,"noShowLimitTime":1,"other":"退改签需要提前三个工作日联系客服","partEndorse":1,"partEndorsePrice":1,"partRefund":1,"partRefundPrice":1,"penalty":2,"refund":"-","specialNoShow":0},"ticketInvoiceType":0,"ticketTimeLimit":120},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"}],"status":200}
gson序列化结果:
{"msg":"成功","routings":[{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"027e1965-d469-4686-823d-6943c912b13b","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]}],"status":200}
Like as below:
var dict = new Dictionary<int, string>
{
[123] = "666",
[456] = "999"
};
var json = JSON.ToJSON(dict);
the serialized json string is :
[{"k":123,"v":"666"},{"k":456,"v":"999"}]
but what i want is :
[{123:"666"},{456:"999"}]
So is it a bug for serializing dictionary with the key to int type ???
The net4 define is only specified for Debug/AnyCPU, it is missing for Release builds.
Hi~
When I use RegisterCustomType for some specified class usually meaning I want Serialize or Deserialize the Object with specified function. But ,if the class is a dictionary-like(just like ,not implement from IDictionary interface) the function i registered will not be invoke
Are there attributes for serializing private fields and ignoring public properties like Json,Net has:
[JsonProperty("statuses")]
private SimpleTweet[] statusesIn;
[JsonIgnore]
public SimpleTweet[] statuses;
I tried [XmlElement(ElementName = "statuses")]
and could not find any usage examples in your unit tests.
Thanks.
PS: .NET35 version
JSON.ToObject(stringValue) manipulating with global settings!
Here stack:
JSON.ToObject< TValue >(stringValue)
->
public static T ToObject< T >(string json)
{
return new deserializer(JSON.Parameters).ToObject< T >(json); // Oops...
}
->
public deserializer(JSONParameters param)
{
this._params = param; // O-o !
}
->
public T ToObject< T >(string json)
{
Type type = typeof (T);
object obj = this.ToObject(json, type);
if (!type.IsArray)
return (T) obj;
if ((obj as ICollection).Count == 0)
return (T) (object) Array.CreateInstance(type.GetElementType(), 0);
return (T) obj;
}
->
public object ToObject(string json, Type type)
{
this._params.FixValues();
Type type1 = (Type) null;
if (type != (Type) null && type.IsGenericType)
type1 = Reflection.Instance.GetGenericTypeDefinition(type);
if (type1 == typeof (Dictionary< , >) || type1 == typeof (List< >))
this._params.UsingGlobalTypes = false; // Bug here ! <----
this._usingglobals = this._params.UsingGlobalTypes;
object parse = new JsonParser(json).Decode();
...
fastJSON is a great basic library that I use for years in most of my programs.
In order to use dynamic I decide to upgrade from 1.0 to 2.1.5.
But when I compiled, the method ToDynamic
is not exists in the DLL.
I found the compile condition net4
seems to working in VS2015 and SharpDeveloper.
So I tried to remove the compile condition line in the following code:
#if net4
/// <summary>
/// Create a .net4 dynamic object from the json string
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
public static dynamic ToDynamic(string json)
{
return new DynamicJson(json);
}
#endif
Then I compiled in vs2015 and got the DLL with ToDynamic().
But SharpDevelop was unable to compile and raised Error CS0246: unabled to find “DynamicJson”.
I think there must be a better way to compile DLL with dynamic.
Can anyone help me , thanks .
Hi, I got confused with this line of code against it's comment:
https://github.com/mgholam/fastJSON/blob/master/fastJSON/JSON.cs#L164
The comment on this line says:
// FEATURE : **enable** extensions when you can deserialize anon types
But the code next line disabled param.UseExtensions
property:
if (param.EnableAnonymousTypes) { param.UseExtensions = false; param.UsingGlobalTypes = false; }
Is it my misunderstanding?
And, should this line be moved into JSONParameters.FixValues()
method which was designed to do this and was called earlier in this ToJSON(object obj, JSONParameters param)
method?
'fastJSON net35' is only enabled for Debug/AnyCPU, not in Release/AnyCPU
Hello! I have a problem trying to deserialize Dictionary<string, object> where including objects also could be Dictionary<string, object> or custom object.
Method JSON.ToObject<Dictionary<string, object> doesn't deserialize correctly. It's casting any objects in a dictionary to System.Object without checking if it IDictionary. As result, if I use custom Object in dictionary JSON can't deserialize it.
Here is code example:
Dictionary<string,object> dict = new Dictionary<string, object>();
Dictionary<string, object> pos = new Dictionary<string, object>();
pos.Add("lat", 0.123123d);
pos.Add("lon", 0.323123d);
string name = "foo";
int level = 25;
SomeClass[] sc = new SomeClass[2];
sc[0] = new SomeClass(123,"map");
sc[1] = new SomeClass(567,"zone");
dict.Add("pos", pos);
dict.Add("name", name);
dict.Add("level", level);
dict.Add("sc", sc);
string json = JSON.ToJSON(dict);
Dictionary<string, object> d = JSON.ToObject<Dictionary<string, object>>(json);
//d["pos"] type will be System.Object instead of Dictionary.
Hi, I think that this is a bug when i don't have a setter on property which is a List
or any IEnumerable
and the values do not serialize, example:
public class ServiceDescription
{
public ServiceDescription()
{
Projects = new List<ProjectDescription>();
}
public string ProjectRoot { get; set; }
public List<ProjectDescription> Projects { get; }
}
After JSON.ToJSON(serviceDescription)
I become only {"projectRoot":null}
the method (ToJSON or ToNiceJSON ) returns string is "\u59D3\u540D" ,the unicode string is "姓名",how to convert it to readable ?
F#'s record type doesn't come through. E.g.,
{"$types":{"Wrapper.Functions+Error, Wrapper, Version=0.0.0.0, Culture=neutral, PublicKe
yToken=null":"1"},"$type":"1"}
I created the following record:
type Error = {Message: string}
let result = fastJSON.ToJson {Message = "my string"}
I tried just passing an exception
object, the results were better but for some reason it didn't pass the Message
property. I'm just using a string for now.
{"$types":{"System.FormatException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089":"1"
},"$type":"1","HelpLink":null,"Source":"mscorlib","HResult":-2146233033}
There was a problem when trying to deserialize a byte array because the proper conversion from base64 encoded string to byte array was missing.
My fix would be:
private void ReadDataTable(List<object> rows, DataTable dt)
{
dt.BeginInit();
dt.BeginLoadData();
List<int> guidcols = new List<int>();
List<int> datecol = new List<int>();
List<int> bytearraycol = new List<int>();
foreach (DataColumn c in dt.Columns)
{
if (c.DataType == typeof(Guid) || c.DataType == typeof(Guid?))
guidcols.Add(c.Ordinal);
if (c.DataType == typeof(byte[]))
bytearraycol.Add(c.Ordinal);
if (_params.UseUTCDateTime && (c.DataType == typeof(DateTime) || c.DataType == typeof(DateTime?)))
datecol.Add(c.Ordinal);
}
foreach (List<object> row in rows)
{
object[] v = new object[row.Count];
row.CopyTo(v, 0);
foreach (int i in guidcols)
{
string s = (string)v[i];
if (s != null && s.Length < 36)
v[i] = new Guid(Convert.FromBase64String(s));
}
foreach (int i in bytearraycol)
{
string s = (string)v[i];
if (s != null)
v[i] = Convert.FromBase64String(s);
}
if (_params.UseUTCDateTime)
{
foreach (int i in datecol)
{
string s = (string)v[i];
if (s != null)
v[i] = CreateDateTime(s);
}
}
dt.Rows.Add(v);
}
dt.EndLoadData();
dt.EndInit();
}
Cannot use fastjson on xamarin ios, because depends on System.Reflection.Emit, which is not supported by xamarin iOS. Please help
I would like to generate JSONs with 4 spaces per tab, which is more common than the 3 that fastJSON uses.
else if (_params.KVStyleStringDictionary == false && obj is IDictionary &&
obj.GetType().IsGenericType && obj.GetType().GetGenericArguments()[0] == typeof(string))
is possible if "obj.GetType().GetGenericArguments()[0] == typeof(int)" convert key to string type ?
with a parameter "IntDictionaryKeyToString" true/false by default false
tks
By default SerializerMaxDepth throws exception, could you make so it skip value serialization instead throwing exception.
list对象序列化
fastjson版本: 1.2.42
调用方法: JSON.toJSONString(obj)
fastjson序列化结果:
{"msg":"成功","routings":[{"adultPrice":4220,"adultTax":512,"adultTaxType":0,"applyType":0,"childPrice":3170,"childTax":392,"childTaxType":0,"currency":"RMB","data":"05221d9f-cb71-453e-a7d1-3e7f42fdf7d3","fromSegments":[{"aircraftCode":"388","arrAirport":"SYD","arrTime":"2017-12-21T09: 45: 00.000+11: 00","cabin":"L","cabinClass":1,"carrier":"QF","codeShare":false,"depAirport":"HKG","depTime":"2017-12-20T21: 15: 00.000+08: 00","flightNumber":"118","stopCities":""}],"nationalityType":0,"priceType":0,"retSegments":[],"rule":{"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","endorsement":1,"hasBaggage":1,"hasEndorse":1,"hasNoShow":1,"hasRefund":1,"noShowLimitTime":1,"other":"退改签需要提前三个工作日联系客服","partEndorse":1,"partEndorsePrice":1,"partRefund":1,"partRefundPrice":1,"penalty":2,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","specialNoShow":0},"ticketInvoiceType":0,"ticketTimeLimit":120},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"},{"$ref":"$.routings[0]"}],"status":200}
gson序列化结果:
{"msg":"成功","routings":[{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]},{"applyType":0,"ticketTimeLimit":120,"adultTax":512,"data":"834d9873-027e-43a7-9a38-269c33e4d8d2","childTax":392,"adultPrice":4220,"priceType":0,"ticketInvoiceType":0,"rule":{"specialNoShow":0,"partEndorse":1,"other":"退改签需要提前三个工作日联系客服","endorsement":1,"baggage":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","penalty":2,"partRefundPrice":1,"hasRefund":1,"partEndorsePrice":1,"hasBaggage":1,"endorse":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-","hasNoShow":1,"hasEndorse":1,"noShowLimitTime":1,"partRefund":1,"refund":"-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-"},"childTaxType":0,"fromSegments":[{"cabinClass":1,"carrier":"QF","stopCities":"","depTime":"2017-12-20T21: 15: 00.000+08: 00","codeShare":false,"aircraftCode":"388","cabin":"L","arrAirport":"SYD","depAirport":"HKG","arrTime":"2017-12-21T09: 45: 00.000+11: 00","flightNumber":"118"}],"nationalityType":0,"currency":"RMB","adultTaxType":0,"childPrice":3170,"retSegments":[]}],"status":200}
This may seem trite but fastJSON does not conform to C# naming convention. This lack of naming conformity has been used as a reason not to adopt fastJSON. For me to use it I would have to fork my own version. I really don't want to do that for something as trivial as naming convention and compliance.
decimal.MinValue
and decimal.MaxValue
, the result of deserialization is wrong.+/-7.9228162514264337593543950335m
to decimal
, only 17 significant digit perserved.The
decimal
has 29 significant digit when top digit is less than '7' according to MSDN
See the source code from Microsoft as reference
double.NegativeInfinity
, double.PositiveInfinity
, float.NegativeInfinity
, float.PositiveInfinity
.ulong.MaxValue
. For ulong
that has a value greater than long.MaxValue
.IntPtr
and UIntPtr
. Also, for UIntPtr
, there is a extreme case too, is that the UIntPtr has a value greater than long.MaxValue
, it must be treated carefully.Test code:
public class DigitLimit
{
public decimal Mmin = decimal.MinValue; //OK to be serialized but wrongly deserialized to 1
public decimal Mmax = decimal.MaxValue; //OK to be serialized but wrongly deserialized to -1
public decimal MminDec = -7.9228162514264337593543950335m; //OK to be serialized but lost precision in deserialization
public decimal MmaxDec = +7.9228162514264337593543950335m; //OK to be serialized but lost precision in deserialization
//public double Dmin = double.MinValue; //OK to be serialized but can not be deserialized due to bug of .netFX
//public double Dmax = double.MaxValue; //OK to be serialized but can not be deserialized due to bug of .netFX
public double DminDec = -double.Epsilon;
public double DmaxDec = double.Epsilon;
public double Dni = double.NegativeInfinity; //OK to be serialized (however without double quote) but when deserializing throw Exception("Could not find token at index " + --index); @NextTokenCore() JSON.cs
public double Dpi = double.PositiveInfinity; //OK to be serialized (however without double quote) but when deserializing throw Exception("Could not find token at index " + --index); @NextTokenCore() JSON.cs
public double Dnan = double.NaN;
public float Fmin = float.MinValue;
public float Fmax = float.MaxValue;
public float FminDec = -float.Epsilon;
public float FmaxDec = float.Epsilon;
public float Fni = float.NegativeInfinity; //OK to be serialized (however without double quote) but when deserializing throw Exception("Could not find token at index " + --index); @NextTokenCore() JSON.cs
public float Fpi = float.PositiveInfinity; //OK to be serialized (however without double quote) but when deserializing throw Exception("Could not find token at index " + --index); @NextTokenCore() JSON.cs
public float Fnan = float.NaN;
public long Lmin = long.MinValue;
public long Lmax = long.MaxValue;
public ulong ULmax = ulong.MaxValue; //OK to be serialized but when deserializing throw System.OverflowException @private object ChangeType(object value, Type conversionType) JSON.cs
public int Imin = int.MinValue;
public int Imax = int.MaxValue;
public uint UImax = uint.MaxValue;
public IntPtr Iptr1 = new IntPtr(0); //Serialized to a Dict, exception on deserialization
public IntPtr Iptr2 = new IntPtr(0x33445566); //Serialized to a Dict, exception on deserialization
public UIntPtr UIptr1 = new UIntPtr(0); //Serialized to a Dict, exception on deserialization
public UIntPtr UIptr2 = new UIntPtr(0x55667788); //Serialized to a Dict, exception on deserialization
}
Test code:
var oD = new DigitLimit();
var oDj = FastJSON.JSON.ToNiceJSON(oD);
var oD_ = FastJSON.JSON.ToObject(oDj);
var oDj_ = FastJSON.JSON.ToNiceJSON(oD_);
var cmp = oDj == oDj_; //false;
The value of oDj:
{
"$types" : {
"Test.DigitLimit, SK, Version=1.0.6298.39641, Culture=neutral, PublicKeyToken=null" : "1",
"System.IntPtr, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" : "2",
"System.UIntPtr, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" : "3"
},
"$type" : "1",
"Mmin" : -79228162514264337593543950335, //will be deserialized to 1
"Mmax" : 79228162514264337593543950335, //will be deserialized to -1
"MminDec" : -7.9228162514264337593543950335, //will be deserialized to -0.123456789012346
"MmaxDec" : 7.9228162514264337593543950335, //will be deserialized to 0.123456789012346
//"Dmin" : -1.79769313486232E+308, //OK to be serialized but can't be deserialized due to bug of .netFX
//"Dmax" : 1.79769313486232E+308, //OK to be serialized but can't be deserialized due to bug of .netFX
"DminDec" : -4.94065645841247E-324,
"DmaxDec" : 4.94065645841247E-324,
//"Dni" : -Infinity, //Exception("Could not find token at index " + --index); @NextTokenCore()
//"Dpi" : Infinity, //Exception("Could not find token at index " + --index); @NextTokenCore()
"Dnan" : "NaN",
"Fmin" : -3.402823E+38,
"Fmax" : 3.402823E+38,
"FminDec" : -1.401298E-45,
"FmaxDec" : 1.401298E-45,
//"Fni" : -Infinity, //Exception("Could not find token at index " + --index); @NextTokenCore()
//"Fpi" : Infinity, //Exception("Could not find token at index " + --index); @NextTokenCore()
"Fnan" : "NaN",
"Lmin" : -9223372036854775808,
"Lmax" : 9223372036854775807,
//"ULmax" : 18446744073709551615, //System.OverflowException @private object ChangeType(object value, Type conversionType) JSON.cs
"Imin" : -2147483648,
"Imax" : 2147483647,
"UImax" : 4294967295//,
/* IntPtr/UIntPtr is serialized as a struct without it's actual value,
* but will throw exception on deserialization @private object ChangeType(object value, Type conversionType) JSON.cs
"Iptr1" : {
"$type" : "2",
"Zero" : {
"$i" : 2
}
},
"Iptr2" : {
"$type" : "2",
"Zero" : {
"$i" : 2
}
},
"UIptr1" : {
"$type" : "3",
"Zero" : {
"$i" : 4
}
},
"UIptr2" : {
"$type" : "3",
"Zero" : {
"$i" : 4
}
}*/
}
The value of oDj_:
{
"$types" : {
"Test.DigitLimit, SK, Version=1.0.6298.39003, Culture=neutral, PublicKeyToken=null" : "1"
},
"$type" : "1",
"Mmin" : 1, //not expected!!!
"Mmax" : -1, //not expected!!!
"MminDec" : -7.9228162514264335, //not expected!!!
"MmaxDec" : 7.9228162514264335, //not expected!!!
"DminDec" : -4.94065645841247E-324,
"DmaxDec" : 4.94065645841247E-324,
"Dnan" : "NaN",
"Fmin" : -3.402823E+38,
"Fmax" : 3.402823E+38,
"FminDec" : -1.401298E-45,
"FmaxDec" : 1.401298E-45,
"Fnan" : "NaN",
"Lmin" : -9223372036854775808,
"Lmax" : 9223372036854775807,
"Imin" : -2147483648,
"Imax" : 2147483647,
"UImax" : 4294967295
}
Serializing an ExpandoObject like:
dynamic obj = new ExpandoObject();
obj.hello = "world";
yields: { "key": "hello", "value": "world" } and not { "hello": "world" }
The problem is this test in JsonSerializer.cs in WriteValue():
else if (_params.KVStyleStringDictionary == false && obj is IDictionary &&
obj.GetType().IsGenericType && obj.GetType().GetGenericArguments()[0] == typeof(string))
which fails since even tho ExpandoObject is a Dictionary<string, object> it is not generic (at least in Mono). I've not tried this in .NET.
There is a simple fix for this which I can PR - let me know!
i having a Class named "AC", then i have define
Dictionary<string, List<AC>> AdjustConfig;
public class AC { public AC() { } public decimal Lo { get; set; } public decimal Ratio { get; set; } }
ToObject<Dictionary<string, List>>(jsonstr) is't work
In the Fastjson 1.2.43 version, the method parseobject is treated as a dead loop。
The following test source:
public static <T> T parseObject(String text, Class<T> clazz) {
return parseObject(text, clazz);
}
Hi,
I'm reading a file and put the result into an array of byte[] from the server, I've built a proxy with fastJSON that deserialize it back, the json returned from the server look like this:
{
"Meta": {
"ResponseType": "Single",
"Success": true,
"CurrentPage": 1,
"TotalPages": 1,
"TotalResults": 1,
"Messages": []
},
"Results": [
"dGVzdA=="
]
}
It fails calling "private object ChangeType(object value, Type conversionType)" last line:
return Convert.ChangeType(value, conversionType, CultureInfo.InvariantCulture);
before that line I've added:
// 2016-04-02 - Enrico Padovani - proper conversion of byte[] back from string
if (conversionType == typeof(byte[]))
return Convert.FromBase64String((string)value);
and now it works as expected.
Enrico
Negative numbers like -1 are deserialized as decimal, positive numbers as long.
It is a consequence of JsonParser.cs line 310, but the intention of the condition is unclear to me.
if (index - startIndex < 20 && json[startIndex] != '-')
Hello i have the following jstring:
{ "Section1" : { "Key1" : "Value1", "Key2" : "Value2", "Key3" : "Value3", "Key4" : "Value4", "Key5" : "Value5" } }
That is generated from calling fastJSON.JSON.ToNiceJSON on a Dictionary<string, Dictionary<string,string>> object.
When i try and call fastJSON.JSON.ToObject<Dictionary<string, Dictionary<string,string>>(jsontext) it just fails every time.
I just for the moment went ahead and made a new object of type Dictionary<string, StringDictionary> that is parsed just fine but i would rather not use StringDictionary.
Any suggestions would be welcome. (I prefer not to use extensions though)
Edit: I am using the latest source from github and i have tried with Net4 directive and without.
DateTimeKind.Utc
dates become DateTimeKind.Local
when parsed, time is parsed correctly.
I guess the problem is around here.
The date should probably be constructed as either Local
or Utc
depending on the value of utc
boolean.
The constructed data should then be converted to the other format, only if _params.UseUTCDateTime
differs from utc
.
Thanks! :)
The JSON standard specify that a string could contains
And prohibit the use of control characters and the character (\ and ") because they will cause conflict,
In the function JsonParser.ParseString
\uGGGG
.Your article:
https://www.codeproject.com/Articles/159450/fastJSON
Instructs to use fastJSON.JSON.Instance which doesn't exist (at least in the .NET35 version).
I'm glad it doesn't exist because that's sort of an ugly way to access the library.
Just wanted to make sure you're aware of the discrepancy. If it is different among versions I hope you will adopt a uniform usage.
Great work on this. I hope to lend a hand when possible. It's a nice step up from Json.NET (which is great, but overkill and amazingly yours is faster!).
Cheers!
Can i import fastJSON to my unity project?
Does unity supported?
This code throwing Exception: Cannot determine type
json string it generates:
[{"$types":{"Test":"1"},"$type":"1"},{"$type":"1"}]
void Main()
{
string s = fastJSON.JSON.ToJSON(new Test[]{new Test(),new Test()});
fastJSON.JSON.ToObject<Test[]>(s);
}
public class Test
{
}
Can't view HowTo.md, gets a 404
Could you add function like
public static T ToObject(string json,T o)
so could serialize json into existing object
Does fastJSON supporting Surrogate Serialization?
If not, let us know.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.