Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

a couple more tweaks

  • Loading branch information...
commit 37db4f069487a49b7d7d9c0c898c983155533dce 1 parent cd7660b
@montegoulding authored
View
3  .gitignore
@@ -25,4 +25,5 @@ DerivedData
*.lcext
*.dylib
binaries
-_build
+_build
+build
View
32 README.md
@@ -1,10 +1,8 @@
-mergJSON
-=====
+#mergJSON
A [LiveCode](http://runrev.com) [JSON](http://json.org) encoding/decoding external.
-Author
-------
+##Author
[Monte Goulding](mailto:monte@goulding.ws)
@@ -12,20 +10,22 @@ Support the project by using me as a [consultant](http://goulding,ws) or by buyi
mergJSON uses the Jansson library Copyright (c) 2009-2012 Petri Lehtinen under the terms of the MIT license. See the LICENSE file in the jansson submodule for details.
-License
--------
+##License
This external is available under a dual-license. If you are doing commercial work with it please purchase a commercial license from [mergExt](http://mergext.com) otherwise you are free to use under the GPL 3 license. The intention is that it's free to use wherever [LiveCode](http://runrev.com) is free to use.
-Support
--------
+##Support
Ask it on [StackOverflow](http://stackoverflow.com) and it shall be answered.
-Binaries
---------
+##Binaries
Binaries for this external are available under a free account at [mergExt](http://mergext.com) so there's no point duplicating here.
-Design
-------
+##Installation
+
+Look [here](http://lessons.runrev.com/s/lessons/m/4071/l/6347-how-to-install-3rd-party-externals-for-use-in-the-ide-and-standalone-builder) for installation instructions for the IDE and desktop standalones.
+Look [here](http://www.youtube.com/watch?v=zFTsVu7_QOI) for installation instructions for iOS and Android.
+To install in server then you just need to drop the external into the externals folder. For OS X use mergJSON.dylib rather than mergJSON.bundle on server.
+
+##Design
This external has been implemented to encode/decode UTF8 JSON to a LiveCode array as quickly as possible. Currently externals can not work with multi-dimensional LiveCode arrays so the intention is it is used with two functions like this:
@@ -51,19 +51,19 @@ This external has been implemented to encode/decode UTF8 JSON to a LiveCode arra
For most cases the above is all the documentaion you will need. There are however some quirks to the external you might need to know about.
-Quirk 1
+###Quirk 1
If the external encounters \} as the first char of an array element it will assume the string is already encoded. This is how the recursive function is able to translate a multi-dimensional array into JSON. It's also the only way to get an empty array or object into your JSON by setting the element value to \}\[\] or \}\{\}.
-Quirk 2
+###Quirk 2
If the keys of the array are numbered 1...N where N is the number of elements then the array is encoded as a JSON array. If not it's encoded as a JSON object. It's possible that in some cases you want to force what looks like an array to be an object. If that's the case then use the pForceRootType parameter with a value of "object".
-Quirk 3
+###Quirk 3
Sometimes strings look like numbers so if you need to force a value to be a string then use the pForceRootType parameter with a value of "string". This only works when you are encoding a normal variable rather than an array so you need to pre-parse your array to pre-encode any strings that may look like numbers.
-Quirk 4
+###Quirk 4
If the value looks like a real number it is encoded as an IEEE 754 double. In order to represent the number uniquely a double may need a precision of 15 to 17 decimal places. What this means is that any encoded then decoded doubles may need to be formatted or rounded to the precision you require before displaying it to a user because something like 0.657679 when converted to a double will become 0.65767900000000001. I'm expecting the people at IEEE are smarter than me so I'm not going to mess with that...
View
107 mergJSON.xcodeproj/project.pbxproj
@@ -23,6 +23,18 @@
B2662DED17684D8900E9A174 /* external.c in Sources */ = {isa = PBXBuildFile; fileRef = B262C13316B3F772002D4FEC /* external.c */; };
B285233016B3FBF500159A3F /* mergJSON.c in Sources */ = {isa = PBXBuildFile; fileRef = B285232F16B3FBF500159A3F /* mergJSON.c */; };
B28F3C9716B3F5E1009D2F35 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B28F3C9516B3F5E1009D2F35 /* InfoPlist.strings */; };
+ B2B54CA7176EAD490047920A /* dump.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECA916EC9C2F005E495C /* dump.c */; };
+ B2B54CA8176EAD490047920A /* error.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECAA16EC9C2F005E495C /* error.c */; };
+ B2B54CA9176EAD490047920A /* hashtable.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECAB16EC9C2F005E495C /* hashtable.c */; };
+ B2B54CAA176EAD490047920A /* load.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECAC16EC9C2F005E495C /* load.c */; };
+ B2B54CAB176EAD490047920A /* memory.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECAD16EC9C2F005E495C /* memory.c */; };
+ B2B54CAC176EAD490047920A /* pack_unpack.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECAE16EC9C2F005E495C /* pack_unpack.c */; };
+ B2B54CAD176EAD490047920A /* strbuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECAF16EC9C2F005E495C /* strbuffer.c */; };
+ B2B54CAE176EAD490047920A /* strconv.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECB016EC9C2F005E495C /* strconv.c */; };
+ B2B54CAF176EAD490047920A /* utf.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECB116EC9C2F005E495C /* utf.c */; };
+ B2B54CB0176EAD490047920A /* value.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECB216EC9C2F005E495C /* value.c */; };
+ B2B54CB1176EAD4E0047920A /* mergJSON.c in Sources */ = {isa = PBXBuildFile; fileRef = B285232F16B3FBF500159A3F /* mergJSON.c */; };
+ B2B54CB2176EAD4E0047920A /* external.c in Sources */ = {isa = PBXBuildFile; fileRef = B262C13316B3F772002D4FEC /* external.c */; };
B2FFECB316EC9C2F005E495C /* dump.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECA916EC9C2F005E495C /* dump.c */; };
B2FFECB416EC9C2F005E495C /* error.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECAA16EC9C2F005E495C /* error.c */; };
B2FFECB516EC9C2F005E495C /* hashtable.c in Sources */ = {isa = PBXBuildFile; fileRef = B2FFECAB16EC9C2F005E495C /* hashtable.c */; };
@@ -65,7 +77,7 @@
B28F3C9016B3F5E1009D2F35 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
B28F3C9416B3F5E1009D2F35 /* mergJSON-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "mergJSON-Info.plist"; sourceTree = "<group>"; };
B28F3C9616B3F5E1009D2F35 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
- B2DA6F6016BFB43C00B476A5 /* libmergExt.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libmergExt.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ B2B54CA3176EAD1C0047920A /* mergJSON.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = mergJSON.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
B2FFECA916EC9C2F005E495C /* dump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dump.c; path = mergJSON/jansson/src/dump.c; sourceTree = "<group>"; };
B2FFECAA16EC9C2F005E495C /* error.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = error.c; path = mergJSON/jansson/src/error.c; sourceTree = "<group>"; };
B2FFECAB16EC9C2F005E495C /* hashtable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hashtable.c; path = mergJSON/jansson/src/hashtable.c; sourceTree = "<group>"; };
@@ -94,7 +106,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
- B2DA6F5D16BFB43C00B476A5 /* Frameworks */ = {
+ B2B54CA0176EAD1C0047920A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -132,8 +144,8 @@
isa = PBXGroup;
children = (
B28F3C8D16B3F5E1009D2F35 /* mergJSON.bundle */,
- B2DA6F6016BFB43C00B476A5 /* libmergExt.a */,
B2662DBB17684D1100E9A174 /* libmergJSON.a */,
+ B2B54CA3176EAD1C0047920A /* mergJSON.dylib */,
);
name = Products;
sourceTree = "<group>";
@@ -173,7 +185,7 @@
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
- B2DA6F5E16BFB43C00B476A5 /* Headers */ = {
+ B2B54CA1176EAD1C0047920A /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -219,22 +231,23 @@
productReference = B28F3C8D16B3F5E1009D2F35 /* mergJSON.bundle */;
productType = "com.apple.product-type.bundle";
};
- B2DA6F5F16BFB43C00B476A5 /* mergExt */ = {
+ B2B54CA2176EAD1C0047920A /* mergJSON-Server */ = {
isa = PBXNativeTarget;
- buildConfigurationList = B2DA6F6316BFB43C00B476A5 /* Build configuration list for PBXNativeTarget "mergExt" */;
+ buildConfigurationList = B2B54CA4176EAD1C0047920A /* Build configuration list for PBXNativeTarget "mergJSON-Server" */;
buildPhases = (
- B2DA6F5C16BFB43C00B476A5 /* Sources */,
- B2DA6F5D16BFB43C00B476A5 /* Frameworks */,
- B2DA6F5E16BFB43C00B476A5 /* Headers */,
+ B2B54C9F176EAD1C0047920A /* Sources */,
+ B2B54CA0176EAD1C0047920A /* Frameworks */,
+ B2B54CA1176EAD1C0047920A /* Headers */,
+ B2B54CB4176EAF490047920A /* ShellScript */,
);
buildRules = (
);
dependencies = (
);
- name = mergExt;
- productName = mergExt;
- productReference = B2DA6F6016BFB43C00B476A5 /* libmergExt.a */;
- productType = "com.apple.product-type.library.static";
+ name = "mergJSON-Server";
+ productName = "mergJSON-Server";
+ productReference = B2B54CA3176EAD1C0047920A /* mergJSON.dylib */;
+ productType = "com.apple.product-type.library.dynamic";
};
/* End PBXNativeTarget section */
@@ -258,8 +271,8 @@
projectRoot = "";
targets = (
B28F3C8C16B3F5E1009D2F35 /* mergJSON */,
- B2DA6F5F16BFB43C00B476A5 /* mergExt */,
B2662DBA17684D1100E9A174 /* mergJSON-iOS */,
+ B2B54CA2176EAD1C0047920A /* mergJSON-Server */,
);
};
/* End PBXProject section */
@@ -287,7 +300,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "cp -r \"$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME.bundle\" \"/Users/montegoulding/Dropbox/LiveCode/Externals\"\nopen \"$SRCROOT/$EXECUTABLE_NAME/$EXECUTABLE_NAME.livecode\"";
+ shellScript = "cp -r \"$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME.bundle\" \"$SRCROOT/binaries\"\ncp -r \"$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME.bundle\" \"/Users/montegoulding/Dropbox/LiveCode/Externals\"\nopen \"$SRCROOT/$EXECUTABLE_NAME/$EXECUTABLE_NAME.livecode\"";
};
B2662DEE17684EBB00E9A174 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@@ -302,6 +315,19 @@
shellPath = /bin/bash;
shellScript = "export SYMBOLS=_getXtable\nsh \"$LIVECODE_SDKROOT/tools/lclink.sh\"";
};
+ B2B54CB4176EAF490047920A /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "cp \"$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME\" \"$SRCROOT/binaries/$EXECUTABLE_NAME\"";
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -343,10 +369,22 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
- B2DA6F5C16BFB43C00B476A5 /* Sources */ = {
+ B2B54C9F176EAD1C0047920A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ B2B54CA7176EAD490047920A /* dump.c in Sources */,
+ B2B54CA8176EAD490047920A /* error.c in Sources */,
+ B2B54CA9176EAD490047920A /* hashtable.c in Sources */,
+ B2B54CAA176EAD490047920A /* load.c in Sources */,
+ B2B54CAB176EAD490047920A /* memory.c in Sources */,
+ B2B54CAC176EAD490047920A /* pack_unpack.c in Sources */,
+ B2B54CAD176EAD490047920A /* strbuffer.c in Sources */,
+ B2B54CAE176EAD490047920A /* strconv.c in Sources */,
+ B2B54CAF176EAD490047920A /* utf.c in Sources */,
+ B2B54CB0176EAD490047920A /* value.c in Sources */,
+ B2B54CB1176EAD4E0047920A /* mergJSON.c in Sources */,
+ B2B54CB2176EAD4E0047920A /* external.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -380,6 +418,7 @@
PRODUCT_NAME = mergJSON;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
+ SYMROOT = build;
};
name = Debug;
};
@@ -399,6 +438,7 @@
PRODUCT_NAME = mergJSON;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
+ SYMROOT = build;
VALIDATE_PRODUCT = YES;
};
name = Release;
@@ -430,6 +470,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
+ SYMROOT = build;
};
name = Debug;
};
@@ -453,6 +494,7 @@
LIVECODE_SDKROOT = "$(USER_LIBRARY_DIR)/Application Support/RunRev/Components/LiveCodeSDK";
MACOSX_DEPLOYMENT_TARGET = 10.8;
SDKROOT = macosx;
+ SYMROOT = build;
};
name = Release;
};
@@ -492,21 +534,31 @@
};
name = Release;
};
- B2DA6F6116BFB43C00B476A5 /* Debug */ = {
+ B2B54CA5176EAD1C0047920A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- EXECUTABLE_PREFIX = lib;
- HEADER_SEARCH_PATHS = "\"$SRCROOT/jansson/src/**";
- PRODUCT_NAME = "$(TARGET_NAME)";
+ ALWAYS_SEARCH_USER_PATHS = YES;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ EXECUTABLE_PREFIX = "";
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
+ PRODUCT_NAME = mergJSON;
};
name = Debug;
};
- B2DA6F6216BFB43C00B476A5 /* Release */ = {
+ B2B54CA6176EAD1C0047920A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- EXECUTABLE_PREFIX = lib;
- HEADER_SEARCH_PATHS = "\"$SRCROOT/jansson/src/**";
- PRODUCT_NAME = "$(TARGET_NAME)";
+ ALWAYS_SEARCH_USER_PATHS = YES;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ EXECUTABLE_PREFIX = "";
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
+ PRODUCT_NAME = mergJSON;
};
name = Release;
};
@@ -520,6 +572,7 @@
B2662DDD17684D1100E9A174 /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
B28F3C8716B3F5E1009D2F35 /* Build configuration list for PBXProject "mergJSON" */ = {
isa = XCConfigurationList;
@@ -539,11 +592,11 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
- B2DA6F6316BFB43C00B476A5 /* Build configuration list for PBXNativeTarget "mergExt" */ = {
+ B2B54CA4176EAD1C0047920A /* Build configuration list for PBXNativeTarget "mergJSON-Server" */ = {
isa = XCConfigurationList;
buildConfigurations = (
- B2DA6F6116BFB43C00B476A5 /* Debug */,
- B2DA6F6216BFB43C00B476A5 /* Release */,
+ B2B54CA5176EAD1C0047920A /* Debug */,
+ B2B54CA6176EAD1C0047920A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
View
5 mergJSON/external.h
@@ -609,3 +609,8 @@ template<ExternalHandler u_handler> void ExternalWrapperObjC(char *p_arguments[]
#endif
#endif
+
+#define EXTERNAL_LIBINFO(m_name) \
+extern struct LibInfo __libinfo; \
+__attribute((section("__DATA,__libs"))) volatile struct LibInfo *__libinfoptr_##m_name = &__libinfo;
+
2  mergJSON/jansson
@@ -1 +1 @@
-Subproject commit 68e201add8f856e81fe0fe116adebe2d344cbfa8
+Subproject commit dc2d54d9c6a6a72fd8ed0214e257a47698d20d57
View
5 mergJSON/mergJSON.c
@@ -43,7 +43,7 @@ else { *r_result = x; }}
/* calling function must free the return val */
char * getPrimitiveString(json_t * tJSON) {
- char * tReturn;
+ char * tReturn = NULL;
switch (json_typeof(tJSON))
{
case JSON_TRUE:
@@ -425,6 +425,5 @@ EXTERNAL_DECLARE_FUNCTION("mergJSONDecode", mergJSONDecode)
EXTERNAL_END_DECLARATIONS
#if __IPHONE_OS_VERSION_MIN_REQUIRED
-extern struct LibInfo __libinfo;
-__attribute((section("__DATA,__libs"))) volatile struct LibInfo *__libinfoptr_mergJSON = &__libinfo;
+ EXTERNAL_LIBINFO(mergJSON)
#endif

0 comments on commit 37db4f0

Please sign in to comment.
Something went wrong with that request. Please try again.