Comments (5)
Could you provide a small example?
from mcjson.
var
json:TMcJsonItem;
str:string;
JsonObject:TJsonObject;
begin
try
{ TODO -oUser -cConsole Main : Insert code here }
json:=TMcJsonItem.Create;
JsonObject:=TJsonObject.Create;
try
json.add('topic').AsString:='test';
json.add('content').AsString:='{"name":"111"}';
Str:= json.ToString(false);
writeln('mcJson:'+str);
JsonObject.S['topic']:='test';
JsonObject.S['content']:='{"name":"111"}';
Str:= JsonObject.ToJSON();
writeln('JsonObject:'+str);
Readln;
finally
json.Free;
JsonObject.Free;
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
from mcjson.
If you provide an escaped string representing a JSON object it will work. There is an example in Test11:
'{"k":"{"key":"value"}"}'
McJSON doesn't do the escapes for you.
However, the correct thing would be to throw an exception, since it is not being managed automatically.
I'll improve it to automatically manage this or throw an exception.
Thanks.
from mcjson.
I need mcjson to help me generate the correct json string so that other programs can parse it
from mcjson.
You can write a simple function in order to escape double quotes:
json.add('content').AsString:= MyEscapeDoubleQuotes('{"name":"111"}');
from mcjson.
Related Issues (20)
- Invalid char at pos 1 (UTF8 BOM support) HOT 6
- Excepted got "/" (Comment support) HOT 11
- Unknown escape at pos (escpaing support) HOT 15
- McJsonEscapeString (overzealous) HOT 17
- Slow json generation speed HOT 5
- MCJsonUnEscapeString "/" and "\" missing after unescape HOT 3
- HasKey exception HOT 11
- New empty key destroys the json structure HOT 10
- Check function does not return the wrong position HOT 7
- Check function speed problem HOT 10
- Slower shortener operation (but I realized this is normal because of the AddOrSet search) HOT 7
- McJSONEscapeString TAB problem HOT 3
- How check path exist by not throw error HOT 9
- How fix warning compiler about string HOT 5
- how to get int64 value ? HOT 2
- Range check error HOT 9
- PrjTestMcJSON - many exception HOT 5
- Shorteners self-test result HOT 7
- Test #13 failed in Main branch (trunk rev. #94) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcjson.